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.

Viewing the window.XFC_METADATA object in the Firefox add-on firebug.

Structure of the meta data object

  • XFC_METADATA: The root object that contains all the other entries.
    • attachments: An array of objects with the following entries. Contains a list of all attachments of the current form record. This includes only files that were uploaded with an upload element in the form. It does not include files uploaded in the inbox. This list is empty when the form was not submitted or saved yet. You may access this property in the inbox to check the attachments.
    • alias: Alternative name for this file.
      • changeDate: Date when this file was changed the last time.
      • changeUser: Name of the user who made the last change to the file.
      • createDate: Date when this file was created.
      • createUser: Name of this user who created this file.
      • filename: The filename of this file.
      • formElement: The name of the upload element used for uploading this file.
      • uuid: A unique ID for this file.
    • currentClient: The client to which the current form belongs to.
      • id: The ID of this client.
      • name: The name of this client.
    • currentLanguage: Short name of the current language, eg. en or de.
    • currentLanguageTag: The current language and variant, eg. en-US or de-DE.
    • currentProcess: The current form record. Empty object when the form was not submitted yet.
      • creationDate: The date (formatted according to ISO8601) when this form record was created.
      • id: The ID of this form record.
      • inbox: The name of the current inbox of this form record.
      • lastChangeDate: The date (formatted according to ISO8601) when the data of this form record were last edited.
      • parentVorgangId: If it exists: The ID of the form record that is a parent of the current process.
      • processId: The process ID of this form record, eg. `9b5f788d-7874-4c3c-8131-ccdfd9bcc244`.
      • status:  The name of current state of this form record. The initial state is `Received`.
    • currentProject: Data related to the current form.
      • currentForm: The form version that was used to render the form.
        • id: The ID of this form version.
        • versionNumber: The number of this form version. The first form version is usually 1.
        • isActive: Whether this form version is active.
      • description: The description of this form.
      • id: The ID of this form.
      • status: The state that was used to render the form. Please note that this state may be different from the state of the form record associated (if any) with the current form. For example, when you open a preview of the form in the designer, you can choose to preview the form in different states. Depending on which state you choose, the value of this property will be different. However, as it is a preview, there is no asscociated form record, so XFC_METADATA.currentProcess.status will be empty.
      • title: The title or name of this form.
    • currentSessionID: The current session ID for this form session, eg. 5151BE9E69A42FE78D98580E24B3F23B.
    • currentUser: The currently signed in user. In case the user is not signed in, the user data refers to an anymous user. For example, the first name (currentUser.surename) is set to [Anonymous].
      • active: The current status of this user, ie. whether the user is currently active, locked, or was deleted. One of ACTIVE, LOCKED, or DELETED
      • email: Optional email of this user.
      • forename: The first or given name of this user.
      • ldap: E An object containing the LDAP structure of the user that was authenticated via NTLM. Empty when the user did not authenticate via LDAP. See example of the LDAP data structure
      • mandant: The (optional) name of the client to which this user belongs to.
      • phonenumber: The (optional) phone number of this user.
      • role: The (optional) role to which this user was assigned.
      • surename: The last or family name of this user.
      • title: The form of address of this user. One of KEINE_ANGABE, HERR, FRAU, or DIVERS.
      • usergroups: A list of user groups to which this user belongs.
      • username: The username of this user.
    • pluginResults: The results of a pre-render plugin. A pre-render plugin is executed before the form is rendered and may add data to the form, such as the result of contacting a web service. This object contains the plugin results with one key for each plugin name.
    • serverTime: A Date object representing the current time of the server. Use this instead of `new Date()` to retrieve the current time without having to rely on the client's browser or OS.
    • urlParams: An object of all URL parameters in the URL of the current page.
      • property name: Name of the URL parameter.
      • property value: Value of the URL parameter with that name.
    • urls: A list of URLs for accessing FORMCYCLE-specific resources, such a database queries.
      • attachment: Relative servlet URL for retrieving an attachment of the form. Example: /formcycle/attachment/form/.
      • context: Current context path. Example: formcycle
      • dataquery_db: Relative servlet URL for performing a database query. Example: /formcycle/datenabfragedb/. For further information, see hier.
      • dataquery_ldap: Relative servlet URL for perfomring an LDAP query. Example: /formcycle/datenabfrageldap/.
      • datasource_csv: Relative Servlet-URL zur CSV-Datenquelle. Beispiel: /formcycle/datenquellecsv/. For further information, see hier.
      • datasource_db: Relative servlet URL for performing a database query. Example: /formcycle/datenquelledb/. For more information, see hier.
      • datasource_json: Relative servlet URL for performing a query to a JSON data source. Example: /formcycle/datenquellejson/. For further informatin, see hier.
      • datasource_xml: Relative servlet URL for performing a query to an XML data source. Example:: /formcycle/datenquellexml/. For more information, see hier.
      • plugin: Relative servlet URL to a servlet plugin. Example: /formcycle/plugin/.
      • previewAction: Relative servlet URL rendering a preview of the form. Example: /formcycle/form/preview/3601/1/.
      • submitAction: Relative servlet URL for submitting a form. Example: /formcycle/form/process/3601/1/?lang=de&frid=3819ffe0-4117-45b8-bf81-3933f2dd3414.
    • requestType: How this form was opened, eg. whether it was opened for the first time or in the inbox. Can be one of the following:
      • preview: Rendering a preview of a form
      • print: Printing a form, eg. via the phantom printer plugin.
      • process: Submitting a form
      • provide: Opening an empty form
      • review: Reviewing a form in the inbox
      • alias: for internal use only
      • aliascopy: for internal use only
      • copy: for internal use only
      • form: for internal use only
      • forward: for internal use only
      • image: for internal use only
      • publish: for internal use only
      • reviewplain: for internal use only
      • verify: for internal use only
      • workflow: for internal use only

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){
   return `${XFC_METADATA.urls.context}includes/ressource?pid=${XFC_METADATA.currentProject.id}&name=${encodeURIComponent(filename)}`;
}
// Get the data.
$.get(getResourceURL("myData.json")).then(data => {
 // Do something with the data.
});

Get the user name of the current user:

const username = XFC_METADATA.currentUser.username;

Get the LDAP user of the current user. Must have signed in via LDAP.

const ldapData = XFC_METADATA.currentUser.ldap;

Get the value of the URL parameter named foobar.

const foobar = XFC_METADATA.urlParams.foobar;

Get the current server and set it as the value of an input field named tfServertime.

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

Execute some code only if the form was opened for the first time, ie. when no form record exists yet. May be used to initialize some form fields.

if (!("processId" in XFC_METADATA.currentProcess)) {
 //execute some code
}
Tags:
Copyright 2000-2024