// Example custom lookup method for Text API // this needs to be saved in the ..\site\mods\majic folder as a file with the extension .spl // ########## // This exanple assumes the schema update: // An object has been defined with the name z_custom_table that has (at least) the following attributes: // id (Integer) // sym (String) // An attribute (e.g. z_custom_attribute) has been added to the target object (e.g. cr) that is an SREL to the z_custom_table // ########## // // Set interpreter option that all variables must be explicitly declared #define SYNTAX STRICT int lookup_matchingID_by_symbol(string symbol, string obj_type, object obj, string attribute) { string method; method = "lookup_matchingID_by_symbol"; int matchingID; logf(MILESTONE, "%s: Entering method: %s", method, symbol); logf(VERBOSE, "%s: obj_type=%s", method, obj_type); logf(VERBOSE, "%s: attribute=%s", method, attribute); logf(VERBOSE, "%s: obj.id=%s", method, obj.id); matchingID = (int)expand(format("&{'%s' = z_custom_table.sym->id}", symbol)); if (is_null(matchingID)) logf(MILESTONE, "%s: %s not found", method, symbol); else logf(MILESTONE, "%s: %s found", method, symbol); return matchingID; } // Then an additional line must be added to the text_api.cfg file to use the method. // Let's say that an attribute named z_custom_attribute has been added to the cr object and will be used for Request tickets: // REQUEST.CUSTOM_VALUE=z_custom_attribute.INTEGER.lookup_matchingID_by_symbol // // Finally, Service Desk must be restarted for this to take effect.