<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://greggsmith.net/wiki/index.php?action=history&amp;feed=atom&amp;title=Custom_Lookup_method_for_TextAPI</id>
		<title>Custom Lookup method for TextAPI - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://greggsmith.net/wiki/index.php?action=history&amp;feed=atom&amp;title=Custom_Lookup_method_for_TextAPI"/>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=Custom_Lookup_method_for_TextAPI&amp;action=history"/>
		<updated>2026-04-17T13:58:27Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.1</generator>

	<entry>
		<id>http://greggsmith.net/wiki/index.php?title=Custom_Lookup_method_for_TextAPI&amp;diff=4280&amp;oldid=prev</id>
		<title>Kowy: New page: __NOTOC__ Category:Customizations Category:R12 {{Global Header}} {{Global Announcement}}  == Overview == In text_api.cfg you can configure new attributes, which can be used in stru...</title>
		<link rel="alternate" type="text/html" href="http://greggsmith.net/wiki/index.php?title=Custom_Lookup_method_for_TextAPI&amp;diff=4280&amp;oldid=prev"/>
				<updated>2011-01-11T17:04:49Z</updated>
		
		<summary type="html">&lt;p&gt;New page: __NOTOC__ &lt;a href=&quot;/wiki/index.php?title=Category:Customizations&quot; title=&quot;Category:Customizations&quot;&gt;Category:Customizations&lt;/a&gt; &lt;a href=&quot;/wiki/index.php?title=Category:R12&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:R12 (page does not exist)&quot;&gt;Category:R12&lt;/a&gt; {{Global Header}} {{Global Announcement}}  == Overview == In text_api.cfg you can configure new attributes, which can be used in stru...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__&lt;br /&gt;
[[Category:Customizations]]&lt;br /&gt;
[[Category:R12]]&lt;br /&gt;
{{Global Header}}&lt;br /&gt;
{{Global Announcement}}&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Procedures ==&lt;br /&gt;
=== Step 1. Create Spell method ===&lt;br /&gt;
First at all create free spell method (not connected to any object) with 4 parameters:&lt;br /&gt;
* string value - string value to convert&lt;br /&gt;
* string obj_name - name of object to which the returned value will be set&lt;br /&gt;
* object obj - real object to which the returned value will be set&lt;br /&gt;
* string attribute - name of attribute to which the returned value will be set&lt;br /&gt;
&lt;br /&gt;
Here is the example for custom lookup_cnt_by_phone method:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
uuid lookup_cnt_by_phone(string phone, string obj_type, object obj, string attribute)&lt;br /&gt;
{&lt;br /&gt;
	string method;&lt;br /&gt;
	method = &amp;quot;lookup_cnt_by_phone&amp;quot;;&lt;br /&gt;
	uuid contact;&lt;br /&gt;
&lt;br /&gt;
	logf(MILESTONE, &amp;quot;%s: Entering method: %s&amp;quot;, method, phone);&lt;br /&gt;
	logf(VERBOSE, &amp;quot;%s: obj_type=%s&amp;quot;, method, obj_type);&lt;br /&gt;
	logf(VERBOSE, &amp;quot;%s: attribute=%s&amp;quot;, method, attribute);&lt;br /&gt;
	logf(VERBOSE, &amp;quot;%s: obj.id=%s&amp;quot;, method, obj.id);&lt;br /&gt;
&lt;br /&gt;
	contact = (uuid)expand(format(&amp;quot;&amp;amp;{'%s' = cnt.phone_number-&amp;gt;id}&amp;quot;, phone));&lt;br /&gt;
	if (is_null(contact))&lt;br /&gt;
		logf(MILESTONE, &amp;quot;%s: User not found&amp;quot;, method);&lt;br /&gt;
	else&lt;br /&gt;
		logf(MILESTONE, &amp;quot;%s: User found: %s&amp;quot;, method, contact);&lt;br /&gt;
&lt;br /&gt;
	return contact;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 2. Update configuration in text_api.cfg ===&lt;br /&gt;
To text_api.cfg configuration file insert this line after the last row begining with REQUEST:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
REQUEST.CUSTOMER_PHONE=customer.UUID.lookup_cnt_by_phone&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally restart Service Desk service.&lt;/div&gt;</summary>
		<author><name>Kowy</name></author>	</entry>

	</feed>