Share this page

# Configuring the Service Manager Adapter Converter Property (Script)

The converter section of the Service Manager adapter configuration file contains the `scripts` property. The script file is written in the JavaScript language, and it maps the fields from the Service Manager data model to the OpenText PPM data model and filters the requests.

The `scripts` property is a script file name in the following format:

    scripts=<convert1>.js

This file must reside in the same directory as the adapter, as follows:

    <PPM_Home>/conf/sdi/<adapter name>.ext

where `<adapter name>` is as defined in Table 4-1.

Note: Make sure that no line in a script exceeds 256 characters.

Note: Multiple scripts are supported, using a comma-separated list, in the following format:

    scripts=<convert1>.js,<convert2>.js,...

The adapter searches for these conversion script files in the adapter directory.

The conversion script is responsible for field mapping during the conversion of changes in the Service Manager data model to requests in the OpenText PPM data model, and for filtering the changes and requests.

The script must contain the `convert` function and can contain the optional `preFilter` and `postFilter` functions, as follows:

- preFilter.

  The following function filters the changes before they are converted to the OpenText PPM data model, so that no unnecessary requests are converted:

      preFilter(smChange)

  For example, the following `preFilter` function specifies that Service Manager changes with a Low priority will not be converted and that all other requests will be converted:

      function preFilter(smChange){
          if (smChange.get("Request Urgency")==SM_PRIORITY_LOW)
      	return false;
          else
      	return true;
         }

- convert.

  After identifying the OpenText PPM request attributes that are required for Service Manager changes, use the `convert` function of the conversion script to map fields of Service Manager changes to fields of OpenText PPM requests.

  The following convert function uses the mapping you specify to convert the fields of the change in Service Manager to the fields of the request in OpenText PPM:

      convert(smChange, ppmRFC)

- postFilter.

  The following function filters the converted requests, so that only the desired requests will be imported into OpenText PPM:

      postFilter(ppmRFC)

  For example, the following `postFilter` function specifies that only OpenText PPM requests with a status of Approved will be sent to the PPM Server:

      function postFilter(ppmRFC){
          ppmStatus=ppmRFC.getField("status");
          if (ppmStatus==STATUS_APPROVED)
      	return true;
          else
      	return false;
      }

OpenText Application Quality Management provides a sample conversion script file named `ConvertSMToPPM.js.sample` in the `PPM_Home/conf/sdi/serviceManager-adapter.ext` directory.

Copy the sample file, delete the `.sample` extension in the copy, and revise the copied conversion script as needed. Use the syntax described in the following sections for the conversion script APIs.

## smChange Object

The smChange object represents the Service Manager change. For the `preFilter` and `convert` script functions, use one of the following functions to retrieve fields from the Service Manager change:

- `value=SMRFC.get(String fieldName);`

- `SMRFC.get(`"`Request Urgency`"`)=SM_PRIORITY_LOW;`

## ppmRFC Object

The ppmRFC object represents the OpenText PPM request. For the `convert` and `postFilter` script functions, use the following functions to modify the OpenText PPM request fields:

- Reference ID

  You must use the following function to track the Service Manager change ID in the OpenText PPM request:

      setRefId(String referenceId);

- Time Stamp

  You must use the following function to set the last update time in the OpenText PPM request:

      /**
      * Set the time stamp in long format—that is, the number of
      * milliseconds since January 1, 1970, 00:00:00 GMT
      **/
      setUpdatedTimeStamp(long updatedTimeStamp);
      /**
      * Set the time stamp in the Java simple date format, which is
      * described at the following location:
      * http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
      **/
      setUpdatedTimeStamp(String updatedTimeStamp, String format);

- General Field

  Use the following function to set the value of a general field in the OpenText PPM request:

      setField (String fieldName, String value);

- Date

  Use the following function to set the value of a date field in the OpenText PPM request:

      /**
      * Set the date in long format—that is, the number of
      * milliseconds since January 1, 1970, 00:00:00 GMT
      **/
      setDateValue(String fieldName, long date);
      /**
      * Set the date in the Java simple date format which is
      * described in the following location:
      * http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
      **/
      setDateValue(String fieldName, String date, String format);

- Notes to be added upon creation of a OpenText PPM request

  Use the following function to add a note upon creation of a OpenText PPM request:

      addUserNoteOnCreate(String content, String addedBy, long time;

- Notes to be added upon update of a OpenText PPM request

  Use the following function to add a note upon update of a OpenText PPM request:

      addUserNoteOnUpdate(String content, String addedBy, long time;

- URL reference creation

  If you have configured Service Manager to expose the ticket URL as the `record.url` attribute (see Configure browsing of Service Manager Changes from a URL), you can use the following function to create a URL reference to an Service Manager change:

      addURLReference(String attachmentURL, String attachments);

https://admhelp.microfocus.com PPM 8942
Tips to improve your search results... OpenText™ Project and Portfolio Management Help Center PPM Help 26.2-26.3 All View Local Help Center View Online Help Center Version: