Skip to main content
MediaBeacon University

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.

hiddendefaultfields.png

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());
  • Mandatory Value
    • The same setting as above, but adding UI Element List: View Only, or by using theCurrentField.setVisible(false);.

Additional

  • Other client-side methods are also available and can be interrogated via a browser development console:
    MBAPI.userInfo.png
  • For more information on other fields that you can automatically insert using Client-Side JavaScript, see the "UserApiPublisher" section of the Javadocs.
  • Was this article helpful?