Macro on attached event in AA mode

Document created by Gutis Champion on Sep 28, 2015
Version 1Show Document
  • View in full screen mode

If you will use spell code to attach an event to execute an action macro in AA mode, you may get in to situation when attributes will hold old values. For example you have trigger that on resolution attaches events to the childrens in order to propagate values. Macro:

 

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_super", who, this.persistent_id, 0, "assignee", this.parent.assignee, "impact", this.parent.impact,"category", this.parent.category, "resolution_code", this.parent.resolution_code, "urgency", this.parent.urgency, "group", this.parent.group, "priority", this.parent.priority, "affected_resource", this.parent.affected_resource, "status", this.parent.status); 
if (msg_error()) {
logf(ERROR, "Automatic Child Resolution Error: %s", msg[0]);
}

This macro will work fine in conventional setup and on background server, but will fail on application server. Most probably this is due to fact that macros are executed on background server. Here are the macro code that worked for me on application server also:

 

uuid who;
send_wait(0,top_object(), "call_attr", "cnt", "current_user_id");
who=msg[0];
int i;
i=0;
while (this.parent.status != 'RE')
{
sleep(1);
i++;
if (i == 600)
{
logf(ERROR, "Automatic Child Resolution Error: Could not get new values");
return;
}
}
send_wait(0, top_object(), "call_attr", "api", "update_object_super", who, this.persistent_id, 0, "assignee", this.parent.assignee, "impact", this.parent.impact,"category", this.parent.category, "resolution_code", this.parent.resolution_code, "urgency", this.parent.urgency, "group", this.parent.group, "priority", this.parent.priority, "affected_resource", this.parent.affected_resource, "status", this.parent.status); 
if (msg_error()) {
logf(ERROR, "Automatic Child Resolution Error: %s", msg[0]);
}
1 person found this helpful

Attachments

    Outcomes