- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2020 09:54 PM
Hi ,
I wanted to make a field 'due_date mandatory an read only in new state. So i written client script as needed but the field is only getting mandatory not read only in new state but went we open an existing problem field becomes both mandatory and read only. There are more conditions also for the field to be readonly it is there in the code. But the problem prevails in the New state.
Attaching the code written in client script.
Thanks in Advance.
Thanks,
Glenn
function onLoad() {
// Type appropriate comment here, and begin script below
var cdt = g_form.getValue('opened_at'); //First Date/Time field
var dttype = 'day'; //this can be day, hour, minute, second. By default it will return seconds.
var ajax = new GlideAjax('ClientDateTimeUtils');
ajax.addParam('sysparm_name','getDateTimeBeforeNow');
ajax.addParam('sysparm_fdt', cdt);
ajax.addParam('sysparm_difftype', dttype);
ajax.getXML(doSomething);
function doSomething(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer < 14){
if(!g_user.hasRole('problem_manager')){
g_form.setReadOnly('due_date',true);
}
}
g_form.setMandatory('due_date',true);
}
}
Solved! Go to Solution.
- Labels:
-
Multiple Versions
-
Problem Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2020 04:16 AM
Sorry
Actually was away for day,
the issue was that value wasn't populated so both mandatory and readonly wont work together.
So the solution i did was instead of making it mandatory gave Bussiness rules tovalidate and populate error message as to the field should be mandatory.
Thanks,
Glenn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2020 04:16 AM
Sorry
Actually was away for day,
the issue was that value wasn't populated so both mandatory and readonly wont work together.
So the solution i did was instead of making it mandatory gave Bussiness rules tovalidate and populate error message as to the field should be mandatory.
Thanks,
Glenn