Wait for Condition - Attachments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2010 08:18 AM
Hello,
I've got a Wait for Condition on my workflow and I'm having some problems. I'm trying to check if my current sc_req_item has at least 1 attachment which will allow the workflow to continue. I'm querying the sys_attachment table looking for attachments as per below. However when I add an attachment to an item my workflow doesn't continue:
var att = new GlideRecord('sys_attachment');
att.addQuery('table_sys_id','current.sys_id');
att.query();
//if records exist, there is at least 1 attachment
if (att.next()) {
answer = true;
}
else {
answer = false;
}
Can someone tell me what i'm doing wrong? I tried to wrap the query in a while statement as well but that, as you can imagine didn't work out.
Thanks
-Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2010 08:27 AM
I think you need to nudge the workflow that is running against the request item, this code below does this for me on change requests when a change task is updated to approved:
if(current.u_status > 1)
{
forceReqItemUpdate();
}
function forceReqItemUpdate() {
var wf = new Workflow();
var ri = new GlideRecord("change_request");
if (ri.get(current.parent)) {
wf.runFlows(ri, 'update');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2010 12:33 PM
Thanks for your response. Any reason why this wouldn't work:
Condition: current.short_description == 'Request Item'
var att = new GlideRecord('sys_attachment');
att.addQuery('table_sys_id','current.sys_id');
att.query();
if (att.next()) {
forceReqItemAttachmentUpdate();
}
function forceReqItemAttachmentUpdate() {
var wf = new Workflow();
var ri = new GlideRecord("sc_req_item");
if (ri.get(current.sys_id)) {
wf.runFlows(ri, 'update');
}
}