- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2018 04:36 AM
Hi,
I have to make 'justification' mandatory if the 'planned_start_time' is less than 3 hours from the change is requested. I've tried with business rule, it didn't work. What is the best way to achieve this.
Thanks
Riya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2018 03:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2018 08:16 AM
Hi,
Please review below thread
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2018 08:23 AM
Think you'll need to use an onChange client script on the planned start date field. You'll need to make an ajax call to the server to do the time calculation and return a true or false, you can then use g_form.setMandatory() to make the justification field mandatory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2018 09:33 AM
Hi,
To meets this:
1. Create a Ajax Client Script.
2. Call on form load and Planed Date change
var end=g_form.getValue('u_planned_start_time');
var start=g_form.getValue('opened_at');
var answer;
var ga=new GlideAjax('GetDateDifference');
ga.addParam('sysparm_name','hours');
ga.addParam('sysparm_start',start);
ga.addParam('sysparm_end',end);
ga.getXMLWait();
answer=ga.getAnswer();
if(answer<3)
g_form.setMandatory('u_justification',true);
thanks
Hope this will help you
Please Hit ✅Correct, ⭐️Helpful depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2018 01:54 AM
Hi Upender,
Could you please copy and paste the client script, I can't see anything from the screenshot.
Thank you
Riya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2018 02:02 AM
var end=g_form.getValue('u_planned_start_time');
var start=g_form.getValue('opened_at');
var answer;
var ga=new GlideAjax('GetDateDifference');
ga.addParam('sysparm_name','hours');
ga.addParam('sysparm_start',start);
ga.addParam('sysparm_end',end);
ga.getXMLWait();
answer=ga.getAnswer();
if(answer<3)
g_form.setMandatory('u_justification',true);
Thanks