g_form.save, g_form.submit and gsft method I am saving form but the form is loading again and again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 12:12 AM
Hello Everyone,
I want to thank you all in advance.
I am facing issue while using g_form.save(), g_form.submit(); and gsftSubmit(null, g_form.getFormElement(), 'sysverb_update_and_stay'); method
The requirement is to save the record coming from the script include everything is working fine but when I am trying to save my record in the onchange client script with the above method the form is getting loaded again and again for me.
Here is the code I wrote -
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga_project = new GlideAjax('sn_hr_core.ProjectDetailsPosition');
ga_project.addParam("sysparm_name", "get_ProjectName");
ga_project.addParam('sysparm_usr', g_form.getValue('u_project_number'));
ga_project.getXML(getCal);
function getCal(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('u_project_name', answer);
g_form.save();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2022 11:10 PM
@Ankur
This is the code I wrote in script include -
get_ProjectName: function() {
var res;
var user = this.getParameter('sysparm_usr');
var gr_pro = new GlideRecord('u_project_details_combination');
gr_pro.addQuery('u_project_number', user);
gr_pro.query();
if (gr_pro.next()) {
res = gr_pro.getValue('u_project_name').toString();
}
return res;
},
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2022 11:25 PM
your BR will be looking like this
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr_pro = new GlideRecord('u_project_details_combination');
gr_pro.addQuery('u_project_number', current.u_project_number);
gr_pro.query();
if (gr_pro.next()) {
res = gr_pro.getValue('u_project_name').toString();
}
current.u_project_name = res;
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2022 12:13 AM
Hello Ankur,
I am not able to get the solution with the respective code.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2022 01:22 AM
Glad to know that my script helped.
Please mark my response as correct and helpful to close the thread
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2022 01:28 AM
You can try by removing g_form.save();