Difference between revisions of "Help:Sandbox"
| Line 45: | Line 45: | ||
</processdefinition> | </processdefinition> | ||
</source> | </source> | ||
| + | |||
| + | |||
| + | == code == | ||
| + | |||
| + | <source lang=javascript> | ||
| + | OBJECT cr { | ||
| + | TRIGGERS { | ||
| + | POST_VALIDATE zcr_cancel_events() 444 FILTER(EVENT("UPDATE") && (status { 'RE' -> })); | ||
| + | }; | ||
| + | }; | ||
| + | |||
| + | |||
| + | |||
| + | cr::zcr_cancel_events(...){ | ||
| + | // Building query | ||
| + | send_wait(0, top_object(), "call_attr", "atev", "sync_fetch", "STATIC", format("(event_tmpl = '%s' OR event_tmpl = '%s') AND obj_id = '%s'", "evt:400001", "evt:400002", persistent_id), -1, 0); | ||
| + | if (msg_error()) { | ||
| + | set_error(msg_error()); | ||
| + | set_return_data(msg[0]); | ||
| + | logf(ERROR, "Cannot get attached events for %s %s - %s", type, ref_num, msg[0]); | ||
| + | return; | ||
| + | } else { | ||
| + | logf(SIGNIFICANT, "Got atev list for %s %s", type, ref_num); | ||
| + | } | ||
| + | |||
| + | // Building attached event list from query results | ||
| + | object atev_list; | ||
| + | atev_list = msg[0]; | ||
| + | int thelength; | ||
| + | thelength = 0; | ||
| + | thelength = msg[1]; | ||
| + | if (msg_error()) { | ||
| + | logf(ERROR, "error getting length of atev list for %s %s - %s", type, ref_num, msg[0]); | ||
| + | return; | ||
| + | } else { | ||
| + | logf(SIGNIFICANT, "event list length = %d for %s %s", thelength, type, ref_num); | ||
| + | } | ||
| + | |||
| + | // Canceling all events from list | ||
| + | long index; | ||
| + | int i; | ||
| + | i=0; | ||
| + | for (i; i<thelength; i++) { | ||
| + | send_wait(0, atev_list, "dob_by_index", "DEFAULT", i, i); | ||
| + | if (msg_error()) { | ||
| + | logf(ERROR, "error getting dob_by_index for %s %s - %s", type, ref_num, msg[0]); | ||
| + | return; | ||
| + | } | ||
| + | object to_delete; | ||
| + | to_delete = msg[0]; | ||
| + | send_wait(0, to_delete, "cancel_me"); | ||
| + | if (msg_error()) { | ||
| + | logf(ERROR, "error deleting event %d for %s %s - %s", i, type, ref_num, msg[0]); | ||
| + | return; | ||
| + | } else { | ||
| + | logf(SIGNIFICANT, "successfully canceled event %d for %s %s", i, type, ref_num); | ||
| + | } | ||
| + | } | ||
| + | }</source> | ||
Revision as of 13:44, 11 February 2008
Feel free to try out the wiki syntax in this page.
<rss desc=off>http://www.servicedeskusers.com/forum/index.php?act=rssout&id=8</rss>
This is an example of the workflow to obtain the group members from Servicedesk. Follow the directions exactly
<source lang=xml> </topointnormal>
<topointswimlane>-1</topointswimlane> <to>1170219743489</to> <sequence>-1</sequence> <label /> <description /> >-16777216</lineColor> </transition> </transitions> </duedateprocessing> <preprocessing /> <postprocessing /> <executioncontexts /> <exceptionhandlers /> </subactivity> </nodes>
- <transitions> - <transition id="1164858697231">
<from>1509732671450107440</from> <frompointnormal>-1</frompointnormal> <frompointswimlane>-1</frompointswimlane> <topointnormal>-1</topointnormal> <topointswimlane>-1</topointswimlane> <to>1164858205749</to> <sequence>-1</sequence> <label /> <description /> <done>N</done> <condition /> <lineWidth>1</lineWidth> <lineColor>-16777216</lineColor> </transition> </transitions> </process> </processes> </processdefinition>
</source>
code
<source lang=javascript> OBJECT cr {
TRIGGERS {
POST_VALIDATE zcr_cancel_events() 444 FILTER(EVENT("UPDATE") && (status { 'RE' -> }));
};
};
cr::zcr_cancel_events(...){ // Building query send_wait(0, top_object(), "call_attr", "atev", "sync_fetch", "STATIC", format("(event_tmpl = '%s' OR event_tmpl = '%s') AND obj_id = '%s'", "evt:400001", "evt:400002", persistent_id), -1, 0); if (msg_error()) { set_error(msg_error()); set_return_data(msg[0]); logf(ERROR, "Cannot get attached events for %s %s - %s", type, ref_num, msg[0]); return; } else { logf(SIGNIFICANT, "Got atev list for %s %s", type, ref_num); }
// Building attached event list from query results object atev_list; atev_list = msg[0]; int thelength; thelength = 0; thelength = msg[1]; if (msg_error()) { logf(ERROR, "error getting length of atev list for %s %s - %s", type, ref_num, msg[0]); return; } else { logf(SIGNIFICANT, "event list length = %d for %s %s", thelength, type, ref_num); }
// Canceling all events from list long index; int i; i=0; for (i; i<thelength; i++) { send_wait(0, atev_list, "dob_by_index", "DEFAULT", i, i); if (msg_error()) { logf(ERROR, "error getting dob_by_index for %s %s - %s", type, ref_num, msg[0]); return; } object to_delete; to_delete = msg[0]; send_wait(0, to_delete, "cancel_me"); if (msg_error()) { logf(ERROR, "error deleting event %d for %s %s - %s", i, type, ref_num, msg[0]); return; } else { logf(SIGNIFICANT, "successfully canceled event %d for %s %s", i, type, ref_num); } } }</source>