- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2015 04:18 PM
I am running the script below in the Approval Request email notification's advanced condition section. This condition is running on the Approval table for Approval requests related to Knowledge articles. I created a new True/False field on the Knowledge form called expiring, if the box(field) is checked then I do not want the Approval request notification to be sent. I am having a difficult time getting this to work, any help would be appreciated. The system seems to see the u_expiring's field value as false every single time.
expireso();
function expireso() {
var exp = new GlideRecord("kb_knowledge");
exp.addQuery('sys_id', current.document_id);
exp.query();
var answer;
if ((exp.u_expiring) == "true") {
answer = false;
}
else {
answer = true;
}
return answer;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2015 02:52 PM
Thanks Brad and Julian for your help. I worked with support because nothing seemed to work. The real cause of the issue was the fact that the Approval Request was being generated even before the Knowledge article actually existed at the database level. I resolved this by adding a timer to delay the start of the generation of the approval request by 2 seconds in the workflow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2015 01:27 AM
OK, here is what I would do
From your initial debug, do you have the current.document_id written down ?
If not, get this as we will use this in testing - should be a unique key
First, lets go to your kb_knowledge table and using the breadcrumbs, seach for the record where the sys_id = your document_id
If it returns a record go into the record, check the XML and see what the u_expiring has as a value
If not, then this is the first problem and you would need to look at your current.document_id and work out what field it is mapping against etc
then in a background script, try these
var exp = new GlideRecord("kb_knowledge");
exp.addQuery('sys_id','asdfasdfasdfasdfasdf')
//exp.addQuery('u_expiring',true);
exp.query();
if (exp.next())
gs.print('got me one : ' + exp.u_expiring);
else
gs.print('ah not so good')
this is based on just the record id and should return a record and if it finds it, tell you what the u_expiring value us
the next two are broadly the same, however one is looking for a true/false and the other is looking for a string value of true
var exp = new GlideRecord("kb_knowledge");
exp.addQuery('sys_id','asdfasdfasdfasdfasdf')
exp.addQuery('u_expiring',true);
exp.query();
if (exp.next())
gs.print('got me one : ' + exp.u_expiring);
else
gs.print('ah not so good')
var exp = new GlideRecord("kb_knowledge");
exp.addQuery('sys_id','asdfasdfasdfasdfasdf')
exp.addQuery('u_expiring','true');
exp.query();
if (exp.next())
gs.print('got me one : ' + exp.u_expiring);
else
gs.print('ah not so good')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2015 02:52 PM
Thanks Brad and Julian for your help. I worked with support because nothing seemed to work. The real cause of the issue was the fact that the Approval Request was being generated even before the Knowledge article actually existed at the database level. I resolved this by adding a timer to delay the start of the generation of the approval request by 2 seconds in the workflow.