Placeholder objects

You can use the following objects in a placeholder:

  • sm: Refers to the value of a field in ITSMA Service Management. You can use either fieldName or alias to refer to the value of a Service Management field.
  • ep: Refers to the value of a field in the end point. You can use either fieldName or alias to refer to the value of an end point field.
  • param: Refers to the value of a parameter that is defined in SMIS configuration.
  • context: Refers to the task information as in the following table. context can store shared variable that you can use in other places, for example, callback, condition in value mappings, and post script.

    Task information Description
    internalId The ID of the record in Service Management.
    externalId The ID of the record in the end point.
    object The table name of the object in Service Management.
    action The action of an inbound or outbound request.
    direction The direction of the action: inbound or outbound.
    internalObject

    Refers to a specific record in Service Management. You can perform the following operations with internalObject:

    • Directly modify internalObject to update the record. This operation is usually used for inbound tasks. For example, the following code in Additional Script can directly specify the value of a field:

      context.internalObject["resolution.code"]="Request Rejected"

      It is not recommended that you directly modify the value of a field by manipulating internalObject, because this action causes an inconsistency between the activity log and the actual result. Therefore, internalObject is usually used to perform operations that does not change the record itself, for example, creating activity log, or building relationship with another record.

    • Retrieve certain record information through internalObject in the pre script or post script. For example, the following code retrieves the value of the Resolution Code field through internalObject:

      if(context.action=="Cancel" && context.internalObject['resolution.code']=="Withdrawn by User") context.cancelledBySM = true;

  • vars: Refers to a global variable.
  • mapObj: Refers to the last map object, which contains the final result of field mapping, pre script, and value mapping. You can only use mapObj in the post script. If you modify mapObj in the post script, your modification will overwrite the result of field mapping and value mapping. That is, the value of the corresponding field in the record will be what you specified in the post script.

The following example scenario helps you understand the use of the sm, ep, and mapObj objects:

  • Assume that you configure the field mapping between the following SM and endpoint fields:

    • SM field: resolution.code
    • Endpoint field: properties.CompletionCode
  • Some of the value mapping configurations for these two fields are as follows:

    SM field (resolution.code) Endpoint field (properties.CompletionCode)
    Automatically Closed NoUserResponse
    Not Reproducible NotReproducible
  • In an inbound task, the value of the properties.CompletionCode field is NoUserResponse in the endpoint.

In this scenario, after the field mapping (and before the execution of the pre script), the sm and ep objects are initialized as follows:

  • ep["properties.CompletionCode"]="NoUserResponse"
  • sm["resolution.code"]="NoUserResponse"

You can manipulate these objects in the pre script.

After the value mapping, the mapObj object is initialized as follows (if you do not change these objects in the pre script):

mapObj["resolution.code"]="Automatically Closed"

This is the result of the field mapping and value mapping. If you do not modify this result in the post script, the Resolution Code field of the record will be Automatically Closed.

However, if you modify the result by adding the following code in the post script:

mapObj["resolution.code"]="Not Reproducible"

The previous field mapping and value mapping result will be overwritten, and the Resolution Code field of the record will be Not Reproducible.