Clarity Service Management

SPEL API methods 

08-04-2015 10:13 AM

SPEL API methods are spel methods that are defined on API object, definitions can be found in api.maj file. It seems that these methods are used at the backend of SOAP web services.

 

To call methods defined on particular object we use the following construction:

 

send_wait(0,top_object(), "call_attr", "<object>", "<object_function>", <object_function_parameters>);

 

MethodDescription
update_object_super This method allows to update multiple attributes for the object
insert_object This method allows to create object and define multiple attributes. You should not use this method to create objects that contains reference numbers (cr,chg,iss) since this method will not generate them automaticaly

delete_wc   

This method allows to delete objects that meets defined criteria ( provided by cdtj)
get_access_for_contact This method allows to get contact access type information

get_func_access

This method allows to get code of functional access that is defined for the object
get_system_users This method will get privileged SDM users and their id's
get_attr_list_for_object This method will get all attributes for the object by object name
get_attr_information This method will get object attribute information
get_object_values This method allows to get object attribute values
generic_activity_log This method allows to create activity log for cr,chg and iss objects
notify_contacts This method allows to perform manual notification from spel code. Method will send an email and create activity log entry
add_requestThis method allows to create new request by using template or from the scratch. It also allows to populate properties if they are defined for the category

add_change_order

This method allows to create new change order by using template or from the scratch. It also allows to populate properties if they are defined for the category
add_issueThis method allows to create new issue by using template or from the scratch. It also allows to populate properties if they are defined for the category
get_valid_tasks_wcThis method gets valid workflow task statuses
get_workflowThis method gets number of tasks attached to the object

get_list

This method gets item list by where clause. Returns number of objects found and object list as the object. Most often it should be used in conjunction with get_list_values method
get_list_valuesThis method gets object attribute values from object list that is returned from get_list method
get_val_for_wc This method gets value of single object attribute by where clause
generic_status_change This method updates status of an object eg. cr, chg, iss (provided by utku.alp)
get_properties This method gets properties of the request, change or issue. Returns number of properties found and property list as the object. Most often it should be used in conjunction with get_list_values or dob_by_index method.
update_object This method allows to update multiple object attributes and atributes of related objects.
get_list_length This method gets object list length, the same length that is usualy returned in msg[1] by methods like get_list and etc.
api_select_count This method gets count of the objects by the where clause
fetch_more This method fetches more results to object list if not all of them where requested by get_list method.
delete_workflow This method allows to delete workflow task that is attached to the object (Atention: this method is not supported for request object for more info check the following thread request ticket - insert and delete WorkFlowTask )
add_contact This method allows to create new contact
add_workflow This method inserts workflow tasks for change and issue objects (provided by ConanLam ( (Atention: this method may not be supported for request object for more info check the following thread request ticket - insert and delete WorkFlowTask )
get_group_list 

This method is used to get contact group membership information from grpmem table.

update_lrel 

This method allows to create or delete lrel relation.

 

 

Will update this when more examples comes in.

 

Statistics
1 Favorited
18 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

07-28-2017 05:20 AM

Two words about regular methods and SPEL API: SPEL Optimization: Regular methods Vs SPEL API 

04-13-2017 01:07 PM

Here's an example for using the method attach_chg_to_request.  I rebuilt the Create Change Order button that is displayed on RIP objects because it has a few bugs (E.g. the analyst doesn't save the Initial CO for longer than the time specified in the web.cfg ExclLockSeconds setting).  This custom solution calls attach_chg_to_request once a CO has been created from a request and will always associate the Request to the CO.  The request persid is mapped to the CO string6 field and this method is called whenever string6 changes.  Thank you camja06 for the idea!

 

MODIFY chg POST_CI zAttachChangeToRequest(persistent_id,string6) 100051 FILTER( string6 {} );

 

chg::zAttachChangeToRequest(...)
{

     // The following lines can be un commented for debugging
     
     string method;
     method="chg::zAttachChangeToRequest";
     logf(SIGNIFICANT, "%s started", method);
     
     
     //logf(SIGNIFICANT,method);

     // End debugging lines
     
     // Variables required for this function are defined here
          string          crPersid, chgPersid, desc;
          uuid          who;

     // Argument values that were sent to the function are copied into their respective variables here
          chgPersid          =argv[3];
          crPersid          =argv[6];

     desc = "Change Order ";
          
     send_wait(0,top_object(), "call_attr", "cnt", "current_user_id");
     who=msg[0];     


     send_wait(0, top_object(), "call_attr", "api", "get_object_values", who, chgPersid, 0, "chg_ref_num"); 
     if (msg_error()) { 
       logf(ERROR, "get_failed %s",msg[0]); 
     } 
     else 
     { 
     int i; 
     for (i=0;i<msg_length();i++) { 
       logf(SIGNIFICANT, "msg[%d]: '%s'", i, msg[i]); 
       }
     desc += msg[1] + " created.";
     } 
     
     send_wait(0, top_object(), "call_attr", "api", "attach_chg_to_request", who, crPersid, chgPersid, desc);
     if (msg_error()) { 
       logf(ERROR,"Error %s",msg[0]); 
     } 
     logf(SIGNIFICANT, "%s ended", method);

}

01-27-2017 09:23 PM

Hi Gutis,

 

When try to open the link for get_func_access method send to page https://communities.ca.com/docs/DOC-231163514, this send a error "No authorize".

Do you know something about this? Thanks...

11-02-2016 05:17 PM

Have you tried to pass template persid instead of task code? Since WebService method accepts both parameters, i think this should work on spel level to.

10-31-2016 04:56 AM

Hi Gutis,

 

Just found a reply from you in another thread, is there any way insert workflow tasks using a spel .

 

After trial and error, here is what I got so far:

add_workflow (uuid, //creator user id

string, //chg or iss object persid

string, //wf object persid where you want to insert the task after (if NULL it will insert at the end of the list)

string, //task type code

int, //this is the parameter I cannot figure out, it only takes 0, 2, or 4

//any other value you want to set (see example below)

attributes1, value1,

attributes2, value2

)

Example:

     send_wait(0, top_object(), "call_attr", "api", "add_workflow", who, "chg:402549", "", "APP", 0, 
               "group_task", 1,
               "wf_template", 400504,
               "description", "Auto Added Task 999");

 

Best regards,

Conan

10-31-2016 02:35 AM

Hi Gutis,

 

Thanks for the document.

Do you know how to use the add_workflow method?

add_workflow (uuid, string, string, string, int, ... );

 

Best regards,

Conan

12-16-2015 02:08 AM

good job Gutis , thanks for your effort.

12-16-2015 01:40 AM

What a revelation! One more huge step to total control over CA SDM!

12-15-2015 05:46 PM

It seem that callServerMethod even allows to execute spel code that are defined on the object. I was able to execute the api:api_select_count method

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://www.ca.com/UnicenterServicePlus/ServiceDesk">

   <soapenv:Header/>

   <soapenv:Body>

      <ser:callServerMethod>

         <sid>1870596105</sid>

         <methodName>api_select_count</methodName>

         <factoryName>api</factoryName>

         <formatList></formatList>

         <parameters>

            <!--1 or more repetitions:-->

            <string>chg</string>

            <string>active = 1</string>

         </parameters>

      </ser:callServerMethod>

   </soapenv:Body>

</soapenv:Envelope>

 

 

got the following answer:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <soapenv:Body>

      <callServerMethodResponse xmlns="http://www.ca.com/UnicenterServicePlus/ServiceDesk">

         <callServerMethodReturn xmlns="">&lt;?xml version="1.0" encoding="UTF-8"?>&lt;ServerReturn>

&lt;Param0>10&lt;/Param0>

&lt;/ServerReturn></callServerMethodReturn>

      </callServerMethodResponse>

   </soapenv:Body>

</soapenv:Envelope>

12-15-2015 05:37 PM

Now i am almost sure that api methos are used by CA SDM SOAP web services and was created as the backend for them.

12-11-2015 08:17 AM

update_object method revealed

12-10-2015 08:27 AM

Thank You, guys!

 

Check out the new API method get_properties

12-10-2015 02:17 AM

great job, thanks to both of you Gutis and Chris Hackett

12-09-2015 08:02 PM

We sure can feature it on the Overview page under featured content. Done! I will also be calling it out in the "What You May Have Missed" newsletter coming out this week! It's wonderful to see something like this flourish!

12-09-2015 07:58 PM

Agree! Bravo. This article keeps on getting better and better.

 

Chris_Hackett - Do we still do featured articles? I'd like to suggest popping this one up there for a week.

 

Thanks, Kyle_R.

12-09-2015 06:35 PM

Looks great!

12-09-2015 06:13 PM

Since document grow to big and it was almost imposible to add new content, i have splited it into multiple small documents, from now on this document will serve as the main blog for all others detail SPEL API documents. Chris_Hackett thank you for idea.

12-03-2015 03:05 AM

Thank You utku.alp, i have updated document.

11-27-2015 09:20 AM

Sorry if this is a duplicate message for this method

 

generic_status_change

 

updating status of requests (i guess already available for issue and change

 

Definition:

generic_status_change ( uuid, string, string, string ) ;

uuid - user id

string - persistent_id of the object

string - description

string - status persid

 

uid who;

send_wait(0,top_object(), "call_attr", "cnt", "current_user_id"); 

who=msg[0]; 

send_wait(0, top_object(), "call_attr", "api", "generic_status_change", who, "cr:644851", "Status change description", "crs:5212");

if (msg_error()) { 

  logf(ERROR,"Error %s",msg[0]); 

}

11-25-2015 03:55 AM

I have just tested it by calling getObjectTypeInformation method on cnt object, and the only attribute cost of type double contains datatype value 2006. Since all methods are using strings to pass values, i think that this chapter describes general CA SDM datatypes, and an answer from CA is not quite correct.

11-25-2015 03:22 AM

hi,

i did my statement based on method you described in this document:

get_attr_information

if i use it with attribute with data type DOUBLE,

i receiving 2006 as result.

 

But everything above is true for SPEL and WebServices is another thing.

As I remember all attributes via WebServices are passes as strings within array, so data type didn't matter on WS layer.

Also I reviewed WSDL file and didn't noticed any methods to get Data Type.

 

Also I want to notice that DOUBLE format in SPEL have some problems (or better call it rules?),

example:

int a;

printf(a); // NULL

a = a + 1;

printf(a); // 1

// incorrect

double b;

b = b + 1; // b = NULL;

// correct

double c;

c = 0;

c = c + 1; // c = 1;

but this kinda offtopic : )

11-25-2015 02:42 AM

Hi Kyle I have asked to review documentation, and received the following answer:

Hi Giedrius,

The datatype listed on this page are for the Webservices layer. The value 2006 is an UNKNOWN data type on the webservices layer. The webservices layer datatype do not match exactly with the backend datatype.

cdtj can you comment on this? Since i still have doubts about this.

11-09-2015 02:24 PM

fetching properties of Change order before save   any thing i had missed here!  , I am using get_object_values and get_list methods .

10-29-2015 11:14 AM

Just checked those methods can be used with each other

10-27-2015 06:37 PM

Two new methods:

get_list - very similar to sync_fetch

get_list_values - similar to dob_by_index, but instead of objects, this method gets values for defined attributes for the object.

P.S.

Most probably sync_fetch can be used in conjunction with get_list_values and vice versa get_list in conjunction with dob_by_index. Did not tested that.

10-20-2015 06:41 PM

Those were tricky ones, but anyway new methods are available

add_request

add_change_order

add_issue

10-16-2015 10:04 AM

New methods generic_activity_log and notify_contacts

10-16-2015 03:30 AM

Great document , I'm just a little sad for finding this article too late.

09-25-2015 09:25 AM

New method added get_object_values

09-19-2015 02:51 AM

Thank you cdtj, i have changed document. Please feel free to update this document by yourself.

09-04-2015 06:24 AM

Hi Giedrius,

 

Could  you (a) Check the above post from Timur, check the ITSM 14.1 documentation on the Wiki to see if it is stored there and if so, make a request to review the document and (b) change font size in opening paragraph back to normal size - it seems to have picked up the title text size.

 

Thanks, Kyle_R.

09-04-2015 05:54 AM

little notice about get_attr_information:

  1. //UNKNOWN 2006

is described as UNKNOWN in Admin/Impl guide but it's not true,

2006 - is float/double data type. (WSP: DOUBLE; SPEL: could be defined as float or double);

 

This doc is not correct place to discuss about data types but search pointed me here :)

08-06-2015 09:11 PM

Fantastic article. More SPL documentation is always needed and appreciated.

 

Thanks, Kyle_R.

08-04-2015 02:09 PM

Thank You, Tiago!

08-04-2015 12:49 PM

08-04-2015 12:05 PM

Thanks for sharing this with the community Giedrius!

SPEL API methods

08-04-2015 11:44 AM

Great. Very helpful.

08-04-2015 10:31 AM

Great article, haven't faced this functions before!

One common method from me:

Delete object:

send_wait(0, top_object(), "call_attr", "api",

    "delete_wc",           // function name

    factory,                  // factory

    whereclause,          // where clause

    NULL);

 

Usage example:

uuid cnt_id;

cnt_id = "<SOME CONTACT UUID HERE>";

send_wait(0, top_object(), "call_attr", "api", "delete_wc", "grpmem", format("member=U'%s'", (uuid)cnt_id), NULL); // remove membership of cnt_id from all groups;

Related Entries and Links

No Related Resource entered.