Error on Duration Variable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 07:29 AM
hello team, i need to show error message if time spent is >24h but with UI policy it doesn't work any help?
It only work if i put a number higher that 1 in th Days part
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 08:35 AM
I would suggest using GlideDuration and GlideDateTime to achieve this. Here is an example:
Client script:
var getComparison = new GlideAjax('IncidentUtils2');
getComparison.addParam('sysparm_name','validateDuration');
getComparison.addParam('sysparm_dur', newValue);
getComparison.getXMLAnswer(compare);
function compare(answer){
alert(answer);
}
Script include:
validateDuration: function(){
var longer = false;
var dur = this.getParameter('sysparm_dur');
var durObj = new GlideDuration(dur);
var durVal = durObj.getValue();
var durDateTime = new GlideDateTime(durVal);
var durValue = durDateTime.getNumericValue();
var aDay = 24 * 60 * 60 * 1000;
if(durValue > aDay){
longer = true;
}
return longer;
},