Data privacy notice

 

When this content is loaded, usage information is transmitted to Vimeo and may be processed there.

 

             

Metadata

Modified on Mon, 16 Jan, 2023 at 10:58 PM

The global object window.XFC_METADATA contains meta data related to the currently opened form; such as the state of the form, the user that is currently signed in, the the form record and much more. When you open a form, this object is added automatically and filled with the relevant information.

The object XFC_METADATA has got the following entries. For further details on these properties and nested properties, see the linked documentation:

Outdated properties of XFC_METADATA:


You can use the global JavaScript object window.XFC_METADATA to get access to a variety of information relating to the current form. Here we prefill an input field for an email adress with the email of the user who is currently signed in. We do this only if the form was opened freshly and not submitted yet. Also, as shown in the figure above, the autocomplete feature works even for nested properties.


Examples


Retrieve the user name of the current user

const username = XFC_METADATA.user.userName;


Retrieve LDAP data from the current user

const rawData = XFC_METADATA.user.rawData;


Read the value of an URL parameter named lang

const foobar = XFC_METADATA.urlParams.lang;


Write the server time to an input field

$("[name='tfServertime']").val(XFC_METADATA.serverTime.toString());

Prefill an email input field with the data of current user

$.xutil.onStatus(() => $('[name="tfMail"]').val(XFC_METADATA.user.mail));


Access a form-specific resource

When there is a file named myData.json uploaded as form-specific resource, you can access it as follows:
// Build the URL for a form file
function getResourceURL(filename){
    // Read the ID of the current form
    var pid = String(window.XFC_METADATA.currentProject.id);
    // Take the beginning part of the URL from the metadata object
    var url = XFC_METADATA.urls.context + "includes/ressource?pid=" + pid + "&name=" + encodeURIComponent(filename};
    return url;
}
// We uploaded the file "myData.json" as a form file
$.get(getResourceURL("myData.json"), undefined, function(data) {
  // Do something with the data from the file "myData.json"
});

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article