Clarity Service Management

update_object 

12-11-2015 07:58 AM

SPEL API methods

update_object

This method allows to update multiple object attributes and atributes of related objects.

 

Definition:

update_object( uuid, string, object|nil, object|nil, int, ... ) ;

uuid - user id

string - persistent id of the object. Use this option only if you are runing from bop_cmd or POST_CI trigger, otherwise you will lock your object.

object|nil - reference object may be used instead of persistent id of the object. If this parameter is passed to the method - system will try to do checkin inside of the method and will return an error if no group_leader was passed. Do not use this option if you need to update SRE attribute since it will fail.

object|nil - group_leader

int - defines wich parameter from this parameter is first that defines attribute name, usualy 0 (zero means that next parameter contains first atribute name to populate)

... - name-value pairs for the attributes to update "atribute1", "value1","atribute2", "value2" it may also contain dot references to the attributes of related objects

working example:

when persistent id is used without group leader

 

 uuid who;  
 send_wait(0,top_object(), "call_attr", "cnt", "current_user_id");  
 who=msg[0];   
 send_wait(0, top_object(), "call_attr", "api", "update_object", who, "site:1000104", NULL, NULL, 0, "name", "test123");  
  if (msg_error()) { 
 printf("create failed %s",msg[0]);  
 }

when persistent id is used with group_leader and dot references

  uuid who;  
  object newobject, group_leader;  
  send_wait(0,top_object(), "call_attr", "cnt", "current_user_id");  
  who=msg[0];   
  send_wait(0, top_object(), "get_co_group");  
    if (msg_error()) {  
        printf("Error'%s'", msg[0]);  
        return;  
    }  
 else{  
    group_leader = msg[0];  
 }
  send_wait(0, top_object(), "call_attr", "api", "update_object", who, "loc:27F1BC6523B7CC45936CF7A35BB04EF3", NULL, group_leader, 0, "site.description", "test123");  
   if (!msg_error()) {  
   send_wait(0, group_leader, "checkin");  
  if (msg_error()) {  
   printf("Error'%s'", msg[0]);  
  }    
    }
 else{
 printf("create failed %s",msg[0]);  
 } 

When reference object is used instead of persistent id

  uuid who;  
  object newobject, siteobject, group_leader;  
  send_wait(0,top_object(), "call_attr", "cnt", "current_user_id");  
  who=msg[0]; 
 send_wait(0, top_object(), "get_co_group");  
    if (msg_error()) {  
        printf("Error'%s'", msg[0]);  
        return;  
    }  
 else{  
    group_leader = msg[0];  
 }
 send_wait(0, top_object(), "call_attr", "loc", "dob_by_persid", 0, "loc:27F1BC6523B7CC45936CF7A35BB04EF3");  
 if (msg_error()) {  
 printf("Error %s",msg[0]);  
 }  
 else  
 {
 siteobject = msg[0]; 
 }
  send_wait(0, top_object(), "call_attr", "api", "update_object", who, "", siteobject, group_leader, 0, "description", "reftest7");  
   if (msg_error()) {  
 printf("create failed %s",msg[0]);  
 }  

Statistics
0 Favorited
8 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

10-18-2018 01:15 PM

giedrius

More one problem detected...

In trigger POST_CI, even by setting the user who will make the change (variable who), this is ignored, causing the user who triggered the trigger to be registered in the modification.

Have you ever noticed this behavior?

03-08-2016 05:14 AM

It seems that there is some limitations for using this method:

1. persistent_id can be used only when running from POST_CI trigger, otherwise you will lock the ticket and most probably hang the system

2. If you will use reference object you will not be able to update SREL attributes

Related Entries and Links

No Related Resource entered.