The Now Platform® Washington DC release is live. Watch now!
02-04-2019 09:50 AM
Hi Team,
I want to restrict the users to select change Task Start Date and End Date (I mean it should not less than the change record planned start and end date) outside the Change planned Start Date and planned End Date.
can some one help on this.
Thanks in advance...
Thanks,
Rajashekhar Mushke
Community Leader
Solved! Go to Solution.
02-19-2019 05:23 AM
Hi All,
Thanks for the response, no need to do a GlideRecord here because change task is child table of change request table, we can directly do a dot walking to get the parent table data.
I have created oBefore insert/update business rule on change_task table, now it is working fine.
(function executeRule(current, previous /*null when async*/) {
if((current.planned_start_date < current.change_request.start_date)){
gs.addErrorMessage("The Task Planned Start Date should be within the Change Planned End Date.");
current.setAbortAction(true);
}
})(current, previous);
Hence closing this thread.
02-04-2019 11:32 AM
Hi Rajashekhar Mushke,
Create a script include and call the script include from the glideajax and pass the planned start and end date to check with parent record.
Please mark as helpful.if it solved your problem.
Regards
Raju Thelu
02-04-2019 11:40 AM
You can make these fields read-only using a UI Policy
02-06-2019 11:20 PM
you can either write a after business rule to check if change Task Start Date and End Date is less than change record planned start and end date, then it should either abort the form submission or give some error.
or you can write glide ajax + script include to validate either on onSubmit client script or you can also write onchange() client script ( but you need to write two onchange() client script , one will be on change task start date and other will be on change task end date. )
script example:
var d ='2018-04-10 16:00:00'; // this would be your change task planned start date value
var gr = new GlideRecord('change_request');
gr.addQuery('sys_id','a9e9c33dc61122760072455df62663d2'); // change task field "change request" value
gr.query();
if(gr.next())
{
gs.print(gr.start_date);
if(d <= gr.start_date)
gs.print('change task planned start date should be more than change record planned start date');
else
gs.print('it is good');
}
above script is an example. you can make some modification and add it in script include and based on the if condition you can return the value and use it in glide ajax. or also you can use the script in your business rule on change task table.
hope it will help you.
02-19-2019 05:23 AM
Hi All,
Thanks for the response, no need to do a GlideRecord here because change task is child table of change request table, we can directly do a dot walking to get the parent table data.
I have created oBefore insert/update business rule on change_task table, now it is working fine.
(function executeRule(current, previous /*null when async*/) {
if((current.planned_start_date < current.change_request.start_date)){
gs.addErrorMessage("The Task Planned Start Date should be within the Change Planned End Date.");
current.setAbortAction(true);
}
})(current, previous);
Hence closing this thread.