
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2020 12:42 PM
Is there a good way in a workflow to check if a record exists on a specific table? I would like to do an If step in a workflow and see if the user that is the requester on a record producer also is associated to a record on a custom table that shows that they have signature authority. If they do the next step would be to check if their level of authority is less than or equal to the requested amount before proceeding. If no associated record exists the workflow moves on to the next step in the process.
I think that the script might look something like this, can someone validate that this would accomplish that?
var answer = [];
var gr = new GlideRecord('u_approvers');
gr.addQuery('u_approver', current.u_requested_for);
gr.query();
if (gr.next()) {
answer = true;
}
And then for the level of approval authority I thought that another query to check against the current record might work:
var answer = [];
var gr = new GlideRecord('u_approvers');
gr.addQuery('u_approver', current.u_requested_for);
gr.addQuery('u_authority_level', current.u_contract_amount);
gr.query();
if (gr.next()) {
current.u_contract_amount<=gr.u_authority_level;
answer = true;
}
Any suggestions are greatly appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2020 12:47 PM
Can you try:
answer = ifScript();
function ifScript(){
var answer = 'no';
var gr = new GlideRecord('u_approvers');
gr.addQuery('u_approver', current.u_requested_for);
gr.query();
if (gr.next()) {
answer = 'yes';
}
return answer;
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2020 12:47 PM
Can you try:
answer = ifScript();
function ifScript(){
var answer = 'no';
var gr = new GlideRecord('u_approvers');
gr.addQuery('u_approver', current.u_requested_for);
gr.query();
if (gr.next()) {
answer = 'yes';
}
return answer;
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2020 02:37 PM
Is your question answered??
If yes, please mark my response as correct and helpful and close this thread.
This helps in removing this thread from unanswered list and helps community.
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2020 02:55 PM
Thanks, this worked well for checking if the requester was also an approver with authority and I liked the structure better than my script even though that worked as well.
I am having some trouble validating the approval authority level though. I want to check the that approver's authority level is less than or equal to an amount on the form, but not sure that the formatting is correct. The encoded query that I have for that is:
gr.addEncodedQuery('u_authority_level<=javascript:global.getCurrencyFilter('u_approvers','u_authority_level', 'USD;475000.00')');
When I put that into a script though I receive errors "Parsing error: Unexpected token u_authority_level". I also want it to compare to the current record's field u_revised_contract_total and not a set amount as shown in the encoded query. The script I have though is ignoring this, probably because it isn't formatted correctly:
answer = ifScript();
function ifScript(){
var answer = 'no';
var gr = new GlideRecord('u_approvers');
gr.addQuery('u_approver', current.u_requested_for);
gr.addEncodedQuery('u_authority_level<=javascript:global.getCurrencyFilter', current.u_revised_contract_total);
gr.query();
if (gr.next()) {
answer = 'yes';
}
return answer;
}
Thanks for any thoughts you might have on that.