Blog Post created by TMACUL Champion on Jan 1, 2016

Custom Lookup method for TextAPI


From SDU

Jump to: navigation, search


To make corrections or additions to this article, select the edit tab above.
To discuss or ask questions about this article, select the discussion tab above.



In text_api.cfg you can configure new attributes, which can be used in structured emails to create or modify SD objects. And the definition of a new attribute can use lookup method to convert some text field (i.e. user login) to object ID. A list of all standard conversion methods is in CMDB Administration Guide in chapter Conversion methods on page 189 in R12.1 documentation. And this article describes how to develop custom lookup method.


Step 1. Create Spell method

First at all create free spell method (not connected to any object) with 4 parameters:

  • string value - string value to convert
  • string obj_name - name of object to which the returned value will be set
  • object obj - real object to which the returned value will be set
  • string attribute - name of attribute to which the returned value will be set

Here is the example for custom lookup_cnt_by_phone method:

uuid lookup_cnt_by_phone(string phone, string obj_type, object obj, string attribute)


string method;

method = "lookup_cnt_by_phone";

uuid contact;


logf(MILESTONE, "%s: Entering method: %s", method, phone);

logf(VERBOSE, "%s: obj_type=%s", method, obj_type);

logf(VERBOSE, "%s: attribute=%s", method, attribute);

logf(VERBOSE, "%s:", method,;


contact = (uuid)expand(format("&{'%s' = cnt.phone_number->id}", phone));

if (is_null(contact))

logf(MILESTONE, "%s: User not found", method);


logf(MILESTONE, "%s: User found: %s", method, contact);


return contact;


Step 2. Update configuration in text_api.cfg

To text_api.cfg configuration file insert this line after the last row begining with REQUEST:


Finally restart Service Desk service.

Retrieved from ""