How to Auto populate the 'Due Date' field based on assignment group in problem management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 01:49 AM
Hi,
I have a requirement " How can we auto populate the Due Date field based on assignment group in problem_task table.
example: The assignment group is software then Due date field should auto populate with 5 days from Now and also due date field should be read only.
Like for all the assignment groups the 'due date' field should auto populate with 5 days from Now.
Please help me.
Thanks in Advance.
Regards,
Sravani.P
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 02:03 AM
Hi Sravani ,
did you mean for all the assignment group , due date should be auto populated and read only or for assignment group == Software then due date should be auto populated and read only and for others due date should be auto populated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 02:14 AM
Hi KHAN,
For all the OOB assignment groups the 'Due date' field should auto populate with 5 days from now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 02:27 AM - edited 11-18-2022 02:30 AM
Hi
Please find the scripts below:
// Sorry for the typo: New Value will be assignment group:
Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var gr = new GlideAjax('CostCentre');
gr.addParam('sysparm_name', 'getDueDate');
gr.addParam('sysparm_service', newValue);// Newvalue will duedate
gr.getXML(mycallback);
function mycallback(response) {
var arr1;
var answer = response.responseXML.documentElement.getAttribute('answer');
arr1= JSON.parse(answer);
alert(answer);
alert(arr1);
g_form.setValue('due_date' ,arr1);
g_form.setReadOnly('due_date',true);
}
}
// Script include:
getDueDate: function() {
var grdatetime;
var gruser = this.getParameter('sysparm_service');
var gr = new GlideRecord('sys_user_group');
gr.addQuery('assignment_group', gruser);
gr.query();
if (gr.next()) {
var gr1 = new GlideDateTime();
gr1.addDaysLocalTime(5);
grdatetime= gr1.getDisplayValue();
}
var json = JSON.stringify(grdatetime);
return json;
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 02:32 AM
// Newvalue will duedate
Ignore this comment . On change will be on Assignment group.