Using JavaScript in Upload Metaforms
Abstract
Following are some example of how to use Client-Side JavaScript to extend the function of MediaBeacon's custom metaforms.
Examples
Hidden Default fields in Metaforms
Version: 8.5, 8.6
In the above builds, the combination of "UI Element List: Hidden" and a "Default Value" entered on a custom metaform field does not write metadata upon submission.
Workaround
- Change the UI Element list back the field's default setting, matching the current setting in the "Fields" tab.
- On the field's "onShow" panel enter:
theCurrentField.setVisible(false);
Write information from user's account to metadata upon upload
Version: 8.5, 8.6+
Customers often request the ability to write values from a user's profile into a field in uploaded assets. It can either be supplied as a default value or as a mandatory value.
Note: This method should only be used upload metaforms.
Implementation Description
- Default Value
- On the field's onShow panel, add the following code to insert a user's supplied email address:
theCurrentField.setValue(window.top.MBAPI.userInfo.getEmail());
- On the field's onShow panel, add the following code to insert a user's supplied email address:
Additional
- Other client-side methods are also available and can be interrogated via a browser development console:
- For more information on other fields that you can automatically insert using Client-Side JavaScript, see the "UserApiPublisher" section of the Javadocs.