Field type "Document ID" to be used in a business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2018 03:42 AM
Hello All,
Could anyone help me to query on field type "Documnet id"?. I'm currently using below
(function executeRule(current, previous /*null when async*/) {
var gr1 = new GlideRecord("policy");
gr1.addQuery('number', current.number);
gr1.query();
while(gr1.next()){
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery('document_id', current.sys_id);
gr.query();
while(gr.next()){
if(gr.state == "approved"){
current.state = "published";
current.active = true;
current.update();
action.setRedirectURL(current);
}
}
}
})(current, previous);
Here i'm not able to get into second while loop, field "document_id" is of the type "Document ID".
Sowmya
- Labels:
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2018 04:10 AM
Do you have any approval for the record you have in current.sys_id?
You could try and exchange current.sys_id to an actual sys_id of something you know you have in the approval table just to make sure there are no other errors.
current.sys_id will be the sys_id of the record from where the business rule is triggered

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2018 04:13 AM
I tried to query the field document_id and everything works correctly.
I suggest you to verify that it enters the first while and then print in the log the value of current.sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2018 04:14 AM
Its not the issue with document_id field because I tried my end with the below code and it worked. Can you please verify the current.sys_id value related any approvals exist in sysapproval_approver table.
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery('source_id', current.sys_id); //which has some approval records in approval table
gr.query();
while(gr.next()){
gs.print("value: "+ gr.getDisplayValue('state'));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2018 04:30 AM
Yes, i see the approval record on my policy table available on approval table