Placing a Timer in a workflow is a good idea or not. Not able to figure it out right now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 10:31 AM
Hi All,
I have a workflow on an item where i am checking whether current.requested_for.manager == current.opened_by. If it is Yes it will directly open a task , if it is No it will go for manager approval.
Here is the screenshot of workflow:
Script used in highlighted if condition is as follows:
Current script
// This script needs to set answer to 'yes' or 'no' to indicate the state of the activity.
answer = ifScript();
function ifScript() {
var gr = new GlideRecord('sys_user');
//gr.get(current.request.requested_for);
gr.addQuery('sys_id',current.request.requested_for);
gr.query();
//if(gr.manager == current.opened_by){
if(gr.next()){
gs.log("hi rav");
var man= current.request.requested_for.manager;
gs.log("Manager is " + man);
if(man == current.opened_by){
return 'yes';
}
}
else{
gs.log("OH Ho");
return 'no';
}
}
Earlier Script
// This script needs to set answer to 'yes' or 'no' to indicate the state of the activity.
//
answer = ifScript();
function ifScript() {
var gr = new GlideRecord('sys_user');
gr.get(current.request.requested_for);
if(gr.manager == current.opened_by){
return 'yes';
}
else{
return 'no';
}
}
Anyhow i have to use a 30sec timer as if i don't use timer then it takes requested for same as opened by person.
Can anyone please suggest whether using a timer here is a good idea or bad one.
Regards,
Geet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2019 11:53 PM
Hi Priyanka,
I tried your suggestion as follows but this also didn't work.
answer = ifScript();
function ifScript() {
var gr = new GlideRecord('sys_user');
//gr.get(current.request.requested_for);
gr.addQuery('sys_id',current.request.requested_for);
gr.query();
//if(gr.manager == current.opened_by){
if(gr.next()){
gs.log("hi rav");
var man= current.request.requested_for.manager;
gs.log("Manager is " + man);
if(man == current.opened_by){
//return 'yes';
answer = 'yes';
}
}
else{
gs.log("OH Ho");
// return 'no';
answer = 'no';
}
}
can you suggest something else.
Regards,
Geet

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2019 09:59 AM
How about you put a Wait For condition after you update the Requested For field. You can check if your current.requested_for field got updated before you start with your If block.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2019 02:56 AM