How to get the difference between 2 date fields in scoped application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-11-2023 05:23 AM
Hi,
Please help on this ,
i want to get difference between 2 date fields (start and end dates) and populate in duration field for the scoped application by using client script
i have used the script it's worked for global but for the scoped it is not working
here are the scripts both are in same scoped application
Script include:
please modify this script if anything wrong for the scoped application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-12-2023 05:21 AM - edited â10-12-2023 05:37 AM
Hello @vasu17 ,
It is working on my side. please do exact same script, it would be work.
Enter proper variable names.
Make sure "Applies on target record" & "Applies on Requested items" is True .
Thanks,
Sayali Gurav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-11-2023 06:54 AM
use GlideDateTime subtract method
Your script include won't get called as it's not client callable
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-11-2023 07:53 AM - edited â10-11-2023 08:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-11-2023 08:48 AM - edited â10-11-2023 08:49 AM
Hi @vasu17
The Class in your Script Include was wrongly generated.
It should be looked like below
var DateFormatUtils = Class.create();
DateFormatUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
calculate: function() {
return gs.dateDiff(this.getParameter('sysparm_strt'), this.getParameter('sysparm_end'), false);
},
type: 'DateFormatUtils'
});
Also make sure you grant the correct user role for this Client Callable Script Include.
Cheers,
Tai Vu