Configuring the OpenText PPM Adapter Converter Property (Script)

The converter section of the OpenText PPM adapter configuration file contains the scripts property. The script file is written in the JavaScript language. The script maps the fields from the OpenText PPM data model to the Service Manager 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-4.

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 requests in the OpenText PPM data model to change updates in the Service Manager data model, and for filtering the requests and change updates.

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

  • preFilter.

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

    preFilter(ppmRFC)
  • convert.

    After identifying the Service Manager change attributes that need to be updated from the OpenText PPM requests, use the convert function of the conversion script to map fields of OpenText PPM requests to fields of Service Manager changes.

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

    convert(ppmRFC, smChange)
  • postFilter.

    The following function filters the converted change updates, so that only the desired updates will be applied to the corresponding change in Service Manager:

    postFilter(smChange)

    ALM provides a sample conversion script file named ConvertPPMToSM.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.

ppmRFC Object

The ppmRFC object represents the OpenText PPM request. For the preFilter and convert script functions, use the following function to retrieve request fields from OpenText PPM:

get(String fieldName);

smChange Object

The smChange object represents the Service Manager ticket. For the convert and postFilter script functions, use the following functions to modify the ticket 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 a value of a general field in the OpenText PPM request:

    setField (String fieldName, String value);
  • Date

    Use the following function to set a 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);