- 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:53 PM
- 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:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2022 04:03 PM
do one thing
replace location.reload() in your client script with this line
GlideDialogWindow.get().destroy();
Please mark this answer helpful if it helped you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2022 04:59 PM
thanks it worked , but there's a small detail hahahaha sorry for asking this much , the UI action that is being called in the client script , is not being executed unless I deactivate the UI page
like this
function onSubmit() {
var conf;
if (g_form.getActionName() == 'approve_new_employee') {
conf = confirm('Please confirm account New Employee Approval');
return conf; // Updates the database if confirmed, aborts if canceled
} else if (g_form.getActionName() == 'terminate_employee') {
var c = this;
/**/
if (window === null) {
var dialog = new GlideDialogWindow('show_termination_reason');
dialog.setTitle('Resolve');
dialog.render();
return false;
} else {
spModal.open({
widget: 'terminate_employees',
buttons: 'false'
}
).then(function(reason) {
c.reason = reason;
});
}
return false;
} else
return true;
}
is weird cause it terminates the employee there
if(gs.hasRole('u_itechag.base_hr_manager_lead')) {
//If HR Manager, terminate employee with no approval
current.u_work_status = 'Terminated';
} else {
current.u_work_status = 'Terminating';
}
current.update();
action.setRedirectURL(current);