- 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-19-2018 02:10 AM
Below is Script Include
var GetDateDifference = Class.create();
GetDateDifference.prototype = Object.extendsObject(AbstractAjaxProcessor, {
hours:function(){
var start=new GlideDateTime(this.getParameter('sysparm_start'));
var end=new GlideDateTime(this.getParameter('sysparm_end'));
var sec=gs.dateDiff(start.getDisplayValue(),end.getDisplayValue(),true);
gs.log('getDisplayValueInternal():'+sec);
var hr=(sec/3600);
return hr;
},
type: 'GetDateDifference'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2018 02:51 AM
Hi Upender,
Is the below code a UI policy?
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);
Thank you
Riya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2018 03:57 AM
Same code on form load and Planed Date change
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2018 03:59 AM
Below is same requirement
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2018 04:58 AM
Hi,
If your requirement is fulfilled please close this thread.
Thanks