# Global Utility

Unifi has some functionality that requires access to methods not available to scoped applications. We grant Unifi access to those methods through a single global utility Script Include which you can install via Update Set.

With version 4.0, the Update Set also includes a queue processing job `Unifi dataset events process` which is necessary for Datasets to be processed.

It is strongly advised that you install this utility to get the most out of Unifi.

1. Download Unifi Global Utility.
2. Import the file as an update set, then preview and commit it. You can find more information on how to [Load customizations from a single XML file](https://docs.servicenow.com/bundle/tokyo-application-development/page/build/system-update-sets/task/t_SaveAnUpdateSetAsAnXMLFile.html) in the ServiceNow Product Documentation.

{% file src="<https://555110489-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F77WwgPxoLSydiu2bJgNO%2Fuploads%2FMUlrTTRIyBaaUS4FvUCu%2FUnifi%20Global%20Utility%204.1.2.1.zip?alt=media&token=a6299c35-76e3-49c1-9670-ae448fbf5357>" %}

## Dependent Features <a href="#features" id="features"></a>

### Execute Now <a href="#execute-now" id="execute-now"></a>

Method: `snd_eb_util.executeNow(job)`

This is necessary for Datasets to execute their associated ServiceNow Import Job.

### Get SOAP Response Element <a href="#get-soap-response-element" id="get-soap-response-element"></a>

Method: `snd_eb_util.getSoapResponseElement(xml)`

When working with Scripted SOAP Services, it’s important to be able to set the soapResponseElement directly in order to preserve the exact payload to be sent back to the calling system. This can only be done with the Global Utility.

### Moving Attachments <a href="#moving-attachments" id="moving-attachments"></a>

Method: `snd_eb_util.moveAttachments(attachment_ids, record)`

The ServiceNow scoped attachment API does not support moving attachments from one record to another. This is necessary for inbound attachments which initially reside on the HTTP Request and are then moved to the Target record.

### Run As User <a href="#run-as-user" id="run-as-user"></a>

Method: `snd_eb_util.runAsUser(user, fn)`

On occasion, Unifi needs to run some code as the given user. This is necessary things like replaying requests.

### Jelly Processing <a href="#jelly-processing" id="jelly-processing"></a>

Method: `snd_eb_util.runJelly(jelly_code, vars)`

Jelly processing is not supported in the ServiceNow scoped API’s, however it is very useful for XML processing. Use of the Global Utility drastically improves XML payload capabilities if you are working with XML payloads.

### Script Validation <a href="#script-validation" id="script-validation"></a>

Method: `snd_eb_util.validateScript(script, scope)`

Used by the Unifi Integration Diagnostic to check scripts for errors.

### Binary Attachment Handling <a href="#binary-attachment-handling" id="binary-attachment-handling"></a>

Method: `snd_eb_util.writeAttachment(record, filename, content_type, data)`

The Scoped Attachment API does not support writing binary attachments which can cause problems when receiving things like Word documents or PDF’s. This method allows Unifi to use the global attachment API to write those files to the database meaning they will work properly.

### Update Set Packaging <a href="#update-set-packaging" id="update-set-packaging"></a>

Method: `snd_eb_util.packager.*`

The packager methods included in the global utility allow Unifi to automatically export all the components of an integration in one easy step. The packager methods will allow Unifi to create an update set for the integration, add all the configuration records to that update set, and export it as a file download from the Integration page on the Unifi Integration Designer portal.

### Web Service Creation <a href="#web-service-creation" id="web-service-creation"></a>

Method: `snd_eb_util.web_service.*`

The web service methods included in the global utility allow Unifi to automatically create and update REST Methods used by Unifi integrations.

### Trigger Rule Creation <a href="#trigger-rule-creation" id="trigger-rule-creation"></a>

Method: `snd_eb_util.trigger_rule.*`

The trigger methods included in the global utility allow Unifi to automatically create a Trigger Business Rule on a table if one doesn't already exist.

### Dataset Create Data Source <a href="#dataset-create-data-source" id="dataset-create-data-source"></a>

Method: `snd_eb_util.datasetCreateDataSource(dataset, attachment)`

Create a data source for datasets to use when importing data.

### Dataset Delete Scheduled Import <a href="#dataset-delete-scheduled-import" id="dataset-delete-scheduled-import"></a>

Method: `snd_eb_util.datasetDeleteScheduledImport(scheduled_import_id)`

Delete a scheduled import that belongs to and was created by a Dataset. Used when deleting a Dataset.

### Dataset Delete Transform Map <a href="#dataset-delete-transform-map" id="dataset-delete-transform-map"></a>

Method: `snd_eb_util.datasetDeleteTransformMap(transform_map_id)`

Delete a transform map that belongs to and was created by a Dataset. Used when deleting a Dataset.

### Dataset Ensure Transform Map <a href="#dataset-ensure-transform-map" id="dataset-ensure-transform-map"></a>

Method: `snd_eb_util.datasetEnsureTransformMap(dataset)`

Update a transform map for a Dataset to use when importing data. Used when building a Dataset.

### Dataset Update Transform Map Fields <a href="#dataset-update-transform-map-fields" id="dataset-update-transform-map-fields"></a>

Method: `snd_eb_util.datasetUpdateTransformMapFields(dataset)`

Update the coalesce fields for a transform map. Used when building a Dataset.
