- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 03:45 AM
hi all,
i'm trying to run a query on an incident record in a workflow which should take the sys_id of the incident ticket reference and query the sys_journal_field table along with the value of the worknote being passed....
My query is returning true constantly despite the worknote not existing
i'm hoping this is a simple thing but i'm not sure where i'm going wrong with the script if anyone could take a look?
I'd really appreciate it!
Cheers.
Code below:
answer = ifScript();
function ifScript() {
var gr = new GlideRecord('sys_journal_field');
gr.addQuery('element_id',current.sys_id);
gr.addQuery('Value','Ticket Auto-Assigned - Flow Complete and will not run again');
gr.query();
if( gr.next() ) {
return 'yes';
} else {
return 'no';
}
}
Solved! Go to Solution.
- Labels:
-
Workflow Automation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 03:58 AM
Please try this one
You mentioned the incorrect field for Value. It should be "value"
answer = ifScript();
function ifScript() {
var gr = new GlideRecord('sys_journal_field');
gr.addQuery('element_id', current.sys_id);
gr.addQuery('value', 'Ticket Auto-Assigned - Flow Complete and will not run again');
gr.query();
if (gr.next()) {
return 'yes';
} else {
return 'no';
}
}
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 03:58 AM
Please try this one
You mentioned the incorrect field for Value. It should be "value"
answer = ifScript();
function ifScript() {
var gr = new GlideRecord('sys_journal_field');
gr.addQuery('element_id', current.sys_id);
gr.addQuery('value', 'Ticket Auto-Assigned - Flow Complete and will not run again');
gr.query();
if (gr.next()) {
return 'yes';
} else {
return 'no';
}
}
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 04:08 AM
thanks for your reply, very silly mistake by me to miss cheers for pointing out.
I've amended to 'value' but my workflow is still not querying correctly still. It now goes straight to no even though the worknote exists
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 04:12 AM
Can you please confirm whether incident reference is a variable on your catalogue item.
if yes then please update the line below with right variable name that hold incident reference
gr.addQuery('element_id', current.variables.varable_name.toString());
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 04:42 AM
hi,
it was a bit odd to be honest when copying and pasting the worknote i had a strange red dot i was removing i tried leaving it and for some reason that was required to make the query work properly!
not sure why but hey ho that's service-now in a nutshell
thanks for your help !