Saving or Updating a field value in the table and on the fly without reloading form view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2022 06:26 AM
We have a tabbed form view having 5 tabs. Each tabs are having different fields.
We have a use case if a "Apply Default" button clicked on form it will save default value of that particular field on table and redirect back to same tab.
Issue here is when we click on "Apply Default" it is refreshing form view (Not browser window) and removing entered values of other fields.
Is there any way we can save default values of a field on the fly without refreshing form view?
We have tried g_form.save() and g_form.submit() but both seem to refresh the form view.
Here is the code written on "onClick" event of "Apply Default" button.
function applyDefaults() {
var profileSysId = g_form.getUniqueValue();
var ga = new GlideAjax("ClientCallableGlideAJAX");
ga.addParam("sysparm_name", "applyDefaultsInProfile");
ga.addParam("sysparm_profileSysId", profileSysId + "");
ga.addParam("sysparm_profileSection", "incident_creation");
ga.getXML();
setStep(2);
gsftSubmit(gel("apply_default_reload"));
}
Here is code written in script of "apply_default_reload" UI action.
gs.setRedirect(current.getLink(true));

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2022 06:42 AM
Hi,
What are you doing with GlideAjax?
If you are storing the form values to the actual record using ajax call then gsftSubmit function call is not required.
Thank you,
Palani
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2022 02:18 AM
Thanks for the reply
In GlideAjax we are setting default value of field and updating record like this.
profileGr.setValue("incident_creation_criteria","severity>=7");
profileGr.setValue("apply_incident_creation_criteria",true);
profileGr.update();
Issue with removing gsftSubmit is that we have used custom UI macro to select multiple values and those values are getting stored in
Servicenow string field as JSON. And when page reloads we populating saved data using Jquery on document.ready()
Therefore We can't remove gsftSubmit call.
$j(document).ready(function () {
//Code of dom manipulation and setting values of HTML elements
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2022 06:46 AM
Hi,
Please refer to this link i hope it helps.
How to prevent page reload in UI Action
Mark Correct or Helpful if it helps.
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2022 03:00 AM
Thanks for the reply,
We have gone through the above thread. It is not we wanted. Thread says about how we can call Server side code (Business Rule) and Client side code both from "Client" UI action using gsftSubmit
and as
Which we don't want as we have used custom UI macro to select multiple values and those values are getting stored in
Servicenow string field as JSON. And when page reloads we populating saved data using Jquery on document.ready()
Therefore We can't remove gsftSubmit call as well.
Screenshot: Field populated using UI macro on document.ready()