PDFsuite Custom Forms Mappings

Handle Data

The Handle Data script handles field mappings between ServiceNow and a PDF Form Field. the script is used to load data into the form, refresh the data on the form, and save the form data back to ServiceNow.

the following variables are provided to the script.

  • stakeholder - an array of strings representing the result fromn the Determin Stakeholder script.
  • currentState - a string representing the current state of the form's workflow.
  • customForm - the sys_id of the UXform record
  • current - a GlideRecord for the current record
  • customData - an object that can be used to pass custom data to and from the client.
  • targets - an array of strings representing target form fields. This is used to limit the number of fields processed on a refresh.
  • helper - A helper class used to handle mappings.
  • action - An object with information on the action to be executed
    export interface IAction {
      action: 'LOAD' | 'SAVE' | 'REFRESH';
      init?: boolean;
    }
    
    The return value should be set to the result variable. the following is the basic structure this script should take. For more info see Handle Data Helper.
try{
    
    // Insert mapping code here
  
    if (action.action === 'SAVE') {
        result.fields = helper.saveFields();
    } else if (action.action === 'REFRESH') {
        result.fields = helper.refreshFields(targets);
    } else {
        result.fields = helper.getFields();
    }

    result.success = helper.getSuccess();
    result.errorMessages = helper.getErrorMessages();
    result.customData = helper.getCustomData();


} catch(e){
    result.error = e;
}

Handle Data Helper

There is a helper class provided to the handle data script used to facilitate mapping data between ServiceNow and a PDF Form.