Clarity Service Management

insert_object 

12-09-2015 03:44 PM

SPEL API methods

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.

 

Definition:

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

uuid - user id

string - factory name

object|nil - NULL (do not know what kind of object should be passed and for what purpose it is used)

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"

working example:

  uuid who;
  object newobject;
  send_wait(0,top_object(), "call_attr", "cnt", "current_user_id");
  who=msg[0];
  send_wait(0, top_object(), "call_attr", "api", "insert_object", who, "zcustomobject1", NULL, 0, "description", description, "time_spent", time_spent, "alg", persistent_id, "request", call_req_id, "contact", analyst);
   if (!msg_error()) {
      newobject = msg[0];
      logf(SIGNIFICANT, "new object id %s", newobject.id); //log new object id
     }
                   

Statistics
0 Favorited
6 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

12-14-2015 04:33 AM

hi,

I tried several scenarios and found that this method overrides current group_leader data.

 

Regular scenario:

- define gl;

- get new dob (obj1) as gl;

- checkout obj2 as gl;

- checkin gl;

result will be 1 object updated, 1 object created.

 

Scenario with this method:

- define gl;

- checkout obj1 as gl;

- call method with gl;

- checkin;

result: new object created, modifications to obj1 were lost.

 

here is code example:

uuid who;

object gl, cr;

int i;

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

for (i=0;i<msg_length();i++) {

  logf(SIGNIFICANT, "msg[%d]: '%s'", i, msg[i]);

}

who = msg[0];

 

send_wait(0, top_object(), "get_co_group");

for (i=0;i<msg_length();i++) {

  logf(SIGNIFICANT, "msg[%d]: '%s'", i, msg[i]);

}

gl = msg[0];

 

send_wait(0, top_object(), "call_attr", "cr", "dob_by_persid", 0, "cr:3180503");

cr = msg[0];

 

send_wait(0, gl, "checkout", cr);

for (i=0;i<msg_length();i++) {

  logf(SIGNIFICANT, "msg[%d]: '%s'", i, msg[i]);

}

 

send_wait(0, cr, "call_attr", "summary", "set_val", format("Now [%s]", (string)now()), "SURE_SET");

for (i=0;i<msg_length();i++) {

  logf(SIGNIFICANT, "msg[%d]: '%s'", i, msg[i]);

}

 

 

send_wait(0, top_object(), "call_attr", "api", "insert_object", who, "alg", gl, 0, "call_req_id", cr.persistent_id, "type", "LOG", "description", now(), "time_spent", (duration)0);

for (i=0;i<msg_length();i++) {

  logf(SIGNIFICANT, "msg[%d]: '%s'", i, msg[i]);

}

 

 

send_wait(0, gl, "checkin");

for (i=0;i<msg_length();i++) {

  logf(SIGNIFICANT, "msg[%d]: '%s'", i, msg[i]);

}

12-10-2015 04:53 PM

I would expect that to object|nil parameter group_leader object should be passed. i have tried the following code:

 

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", "insert_object", who, "site", group_leader, 0, "name", "test3"); 

   if (!msg_error()) { 

   send_wait(0, group_leader, "checkin"); 

  if (msg_error()) { 

   printf("Error'%s'", msg[0]); 

  }   

    }

else{

printf("create failed %s",msg[0]); 

}

 

 

Method accepts group_leader, but when i try to checkin it gives me an error:

Attempt to checkin with nothing checked out.

 

cdtj any thoughts on this?

Related Entries and Links

No Related Resource entered.