Barcode TrueView Integration: On-Hold Reason Mapping

Pradnya Nabar
Tera Guru

This article explains how to implement the On-Hold Reason field mapping feature when the field is mandatory for Barcodes TruwView integration. By default, ServiceNow may fail to update this field when a payload is received for the "On-Hold" state. The following steps outline the implementation used to resolve this mapping issue.

Step 1: Create System Properties for State Mapping

Create System Properties to store the mapping between Barcode Ticket statuses and the corresponding On-Hold Reason choices for the Incident record.

Note: The "State Maps" table is utilized by OOTB scripts to set the Incident state based on Barcode Ticket statuses received via the Scripted REST API payload.

Example: To map the "Awaiting Caller" choice to Barcode statuses 9, 12, 20, 28, 42, 56, 69, 71, etc., create a property with these details:

  • Suffix: barcodes.on_hold.status_ids.awaiting_caller 

  • Application: Barcodes TrueView

  • Type: String

  • Value: 9,12,20,28,42,56,69,71

  • Ignore Cache: True

Repeat this step for other reason choices, using comma-separated status IDs.

Step 2: Update the Scripted REST API

  1. Navigate to the Barcodes API Scripted REST API.

  2. Under the Resources related list, open the Set Ticket Status record.

  3. Locate the updateTicketStatus function in the script.

  4. Insert the script logic after the existing mapping code for "Close Notes."

Note: Ensure you reference the system properties created in Step 1 to map the incoming status IDs to the appropriate ServiceNow choice values.

Script:

            var statusID = barcodeTicketStatus.toString();
            var holdReasonCaller = gs.getProperty('x_bari4_hlpdk_int.barcodes.on_hold.status_ids.awaiting_caller', '');
            var holdReasonVendor = gs.getProperty('x_bari4_hlpdk_int.barcodes.on_hold.status_ids.awaiting_vendor', '');
            var holdReasonConfirm = gs.getProperty('x_bari4_hlpdk_int.barcodes.on_hold.status_ids.pending_confirmation', '');

            var holdReasonMapping = {
                '1': holdReasonCaller.split(','),
                '4': holdReasonVendor.split(','),
                '9': holdReasonConfirm.split(',')
            };

            if (snFieldValues.snStatusChoiceValue == 3) { // If On hold state
                for (var reason in holdReasonMapping) {
                    if (holdReasonMapping[reason].indexOf(statusID) > -1) {
                        ticket.record.hold_reason = reason;
                        break;
                    }
                }
            }


Here, 1, 4 and 9 reresents backend values of the On-hold reason field choices.

Step 3: Update the StatusUpdateHandler Script Include

  1. Navigate to and open the StatusUpdateHandler Script Include.

  2. Locate the updateTicketStatus function.

  3. Apply the same code logic used in Step 2 and save the record.

0 REPLIES 0