Metadata
Sometimes you need to get access to the data of the current user such as his username or mail address, the data of the current form record, such as the form's ID or current state, or the current time of the Xima® Formcycle server. This data is available in the JavaScript object window.XFC_METADATA. The following provides you with a quick overview of all the available data.
Structure of the meta data object
Metadata field | Description | |
---|---|---|
XFC_METADATA | The object containing all the meta data. | |
- attachments | Array of all available attachments. | |
- currentClient | Name and ID of the client to which this form belongs to. | |
- id | The client's ID. | |
- name | The client's name. | |
- currentLanguage | The language in which the form was opened. Can be changed by the parameter "lang". | |
- currentProcess | Data of the current form record. Empty when the form was not submitted yet. | |
- id | The ID of the form record. | |
- processId | The unique process ID of the form record. | |
- status | The current status of the form record. | |
- currentProject | Contains data of the the current form. | |
- id | The ID of form. | |
- title | The title of this form. | |
- description | The description of this form as entered in the form menu. | |
- currentForm | Version of the form. | |
- id | ID of the form version. | |
- versionNumber | The version number. | |
- currentSessionID | The current session ID of the user. | |
- currentUser | Contains data of the current user. Dummy data when the user is not logged in. | |
- title | The user's form of address. Possible values: MISTER, MISS | |
- forename | The user's given name. | |
- surename | The user's family name. | |
- username | The user's user name. | |
The user's mailing adress. | ||
- mandant | The name of the client to which this user belongs to. | |
- active | Whether the user is active. Possible values: ACTIVE, LOCKED, DELETED | |
- role | The role to which this user belongs to. | |
- phonenumber | The user's telephone number. | |
- usergroups | An array containing all the user groups which he is a member of. | |
- inbox | The current inbox of this form record. | |
- ldap | A JavaScript object with the LDAP structure of the user. Empty when the user did not authenticate via NTLM, See also example data structure in firebug. | |
- pluginResults | A JavaScript object with results of pre-render plugins. | |
- serverTime | JavaScript date object with the current server time. | |
- urlParams | A JavaScript object containing all URL parameters of the current URL. | |
- urls | A JavaScript object containing relative URL for various different servlets. | |
- attachment | Servlet for accessing attachments, eg: "/formcycle/attachment/form/". | |
- context | The current context path of the Xima® Formcycle application, eg. "formcycle" | |
- dataquery_db | Servlet for accessing database queries, eg. "/formcycle/datenabfragedb/". | |
- dataquery_ldap | Servlet for accessing LDAP queries, eg "/formcycle/datenabfrageldap/". | |
- datasource_csv | Servlet for accessing CSV data sources, eg "/formcycle/datenquellecsv/". | |
- datasource_json | Servlet for accessing JSON data sources, eg "/formcycle/datenquellejson/". | |
- datasource_xml | Servlet for accessing XML data sources, eg "/formcycle/datenquellexml/". | |
- plugin | Servlet for accessing servlet action plugins, eg "/formcycle/plugin/". | |
- previewAction | Servlet used when previewing the form, eg "/formcycle/form/preview/3601/1/". | |
- submitAction | Servlet used when submitting the form, eg "/formcycle/form/process/3601/1/?lang=de&frid=3819ffe0-4117-45b8-bf81-3933f2dd3414". | |
- requestType | Specifies the context of the current form call possible and usable values: - provide (form delivery) - preview (form preview) - process (processing the form) - print (Printing a form over e.g. PhantomPrinter) - review (form delivery inside the inbox) for internal use: alias, copy, aliascopy, publish, forward |
Examples
Access a form-specific resource
When there is a file named myData.json uploaded as form-specific resource, you can access it as follows:
// Get the URL.function getResourceURL(filename){
var pid = String(window.XFC_METADATA.currentProject.id);
var url = XFC_METADATA.urls.context + "includes/ressource?pid=" + pid + "&name=" + encodeURI(filename);
return url;
}
// Get the data.
$.get(getResourceURL("myData.json"), function(data){
// Do something with the data.
});
Get the user name of the current user:
var benutzername = XFC_METADATA.currentUser.username;
Get the LDAP user of the current user. Must have signed in via LDAP.
var urlParameter = XFC_METADATA.currentUser.ldap;
Get the value of the URL parameter named parameter.
var urlParameter = XFC_METADATA.urlParams.parameter;
Get the current server and set it as the value of an input field named tfServertime.
$('[name=tfServertime]').val(XFC_METADATA.serverTime.toString());
Execute only a function if its a new process. For example set initial data in the form.
if(!XFC_METADATA.currentProcess.processId) {
//execute function
}
//execute function
}