- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2022 02:14 PM
When i click on ok, the record I'm working with is being duplicated and not updated
function onCancel() {
GlideDialogWindow.get().destroy();
return false;
}
function onSubmit() {
var reason = document.getElementById('termination_reason').value;
var date = document.getElementById('termination_date').value;
var sysId = g_form.getUniqueValue();
/*g_form.setValue('u_reason', reason);
g_form.setValue('u_termination', date);
g_form.save();
*/
var employees = new GlideRecord('u_itechag_employees');
employees.addQuery('sys_id', sysId);
employees.query();
if (employees.next()) {
employees.u_reason = reason;
employees.u_termination = date;
employees.update();
}
location.reload();
return true;
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2022 03:56 PM
var terminate_employee = Class.create();
terminate_employee.prototype = Object.extendsObject(AbstractAjaxProcessor, {
Terminate:function()
{
var employees = new GlideRecord('u_itechag_employees');
employees.addQuery('sys_id', this.getParameter('sysparm_id'));
employees.query();
if (employees.next()) {
employees.u_reason = this.getParameter('sysparm_reason');
employees.u_termination = this.getParameter('sysparm_date');
employees.update();
}
},
type: 'terminate_employee'
});
Replace the script below and try
please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2022 03:26 PM
No you need to create that script include in script include table with the name
terminate_employee
You did this or you want any guidance how to do it ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2022 03:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2022 03:29 PM
image is broke please re attach
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2022 03:30 PM
is it showing now?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2022 03:33 PM
yes and replace your script include with this code
var terminate_employee = Class.create();
terminate_employee.prototype = Object.extendsObject(AbstractAjaxProcessor, {
Terminate:function()
{
var employees = new GlideRecord('u_itechag_employees');
employees.addQuery('sys_id', this.getParamter('sysparm_id'));
employees.query();
if (employees.next()) {
employees.u_reason = this.getParameter('sysparm_reason');
employees.u_termination = this.getParameter('sysparm_date');
employees.update();
}
},
type: 'terminate_employee'
});
Also replace your glide ajax like below
var ga = new GlideAjax('terminate_employee');//this is the script include
ga.addParam("sysparm_name", "Terminate"); //this is the function within the script include
ga.addParam("sysparm_id", g_form.getUniqueValue());
ga.addParam('sysparm_reason',reason);
ga.addParam('sysparm_date',date);
ga.getXML(getResponse);
function getResponse(response) {
// do nothing
}