- 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 02:50 PM
okay then normal g_form.setValue('your field back end name',value); this syntax should work
and also put alerts of reason and date variables so that we will to know if value is being accessed or not
please try this and let me know
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2022 02:51 PM
there is a commented section above , which is the way I was trying to call g_form , I think it follows what you just said
g_form.setValue('u_reason', reason);
g_form.setValue('u_termination', date);
g_form.save();
(and should work) but is not updating anything
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2022 02:53 PM
did you try alerting reason and date ?are teh values coming in from HTML ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2022 02:55 PM
yes they come from HTML page , I confirm they are being captured in those variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2022 02:59 PM
lets try one thing
in your HTML code do this change
embed your HTML code between these tow tags
<form>
your HTML code
</form
please try this