Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Script Talk › Button to open media
- This topic has 1 reply, 2 voices, and was last updated 3 days ago by JScottA.
-
AuthorPosts
-
January 19, 2025 at 5:12 AM #51528
G SParticipantI’d like to make a pretty view of my database with a button that opens attached video.
So, I have a filed called “Video” and it has my own 2-minute video in it. On the pretty view I want the button to open the first attachement in the Video field.
Is this possible? Cheers.
January 19, 2025 at 9:26 AM #51531
JScottAParticipantThe following is from the Tap Forms Assistant, an unofficial custom GPT. Maybe it can help you:
To implement a button in your Tap Forms “Pretty View” layout that opens the first attachment in the “Video” field, follow these steps:
1. Prepare the Field
• Ensure your “Video” field is a “File Attachment” field. If it supports multiple files, you should confirm this by checking if “Multi-File Enabled” is selected in the field’s properties.2. Create or Edit the Layout
• Navigate to the Layout Designer by selecting the desired form and choosing the Layouts tab.
• Either create a new layout or edit an existing one.3. Add a Button to the Layout
• Drag a “Button” field from the Layout Designer’s tools panel onto your layout.
• Position it wherever you’d like it to appear in the “Pretty View.”4. Configure the Button Action
• Assign the button an action to execute a script. Scripts in Tap Forms use JavaScript, which allows you to access and manipulate your database.5. Script to Open the First Attachment
Use the Tap Forms JavaScript API to implement the button’s functionality. Here’s an example of a script:
// Assuming the field name is “Video”
var videoFieldName = “Video”;
var videoField = record.getFieldValue(videoFieldName);if (videoField && videoField.length > 0) {
// Open the first attachment
var firstAttachment = videoField[0];
document.showFile(firstAttachment);
} else {
document.alert(“No video attached to this record.”);
}This script:
• Retrieves the attachments from the “Video” field.
• Opens the first attachment using the document.showFile() method.6. Test the Layout
• Save the layout and test the button to ensure it opens the video as expected.For more detailed guidance on layouts and scripting, you can refer to the Tap Forms documentation on Layouts (Page 80) and JavaScript API (Page 58) in the manual .
If you encounter any issues or need further clarification, let me know!
-
AuthorPosts
You must be logged in to reply to this topic.