- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2020 07:46 PM
Hello,
I created a business rule to allow approvers to see the attachments added to the application in the portal.(Global)
Weirdly, however, we realized that we needed to enforce this business rule before an authorization record would occur.
System log:
My boss told me to use 'gs.sleep' as a way to make this delay.(Global)
Refer to:
However, it doesn't work well.
Can you point out what is wrong?
Regards,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2020 08:42 PM
Hi,
gs.sleep() is not allowed in scoped app; you can use this to use some delay
ms -> milliseconds
function sleep(ms) {
var endSleep = new GlideDuration().getNumericValue() + ms;
while ( new GlideDuration().getNumericValue() < endSleep) {
//wait
}
return;
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2020 10:24 PM
Hi,
it does the same but since gs.sleep() is not allowed in scoped so that workaround is used
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2020 10:49 PM
Hi,
Okay, I see.
This caused the business rules that were running when the timer was set to stop working..
I'd like to implement this delay like the timer in the capture above, but can I tell me where the delay is different or where I can point out?
BR is ...(Do I need to change after this settings?)
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2020 11:49 PM
Hi,
what exactly you want to perform? why require a delay in copying the attachment?
Do you want to push the attachments from RITM to approval record so that approver user can see those attachments?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2020 12:32 AM
Hi,
sorry. I'm not sure why the delay is needed, but I've found that setting a timer before the approval record fires works.
Yes, I just want to push the attachment from RITM to the approval record and allow the approver user to view the attachment, so if this is possible I don't need to defer it.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2020 01:19 AM
Hi,
so as soon as approval record is inserted the copy code will copy the attachments immediately; ideally no requirement of sleep as well
But if it is working fine by adding some delay then it should be fine
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader