- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2016 07:25 AM
Hi,
I'm trying to use the new GlideModalForm API and I'm not sure exactly how to utilize the callback function.
Here is my UI Action. Basically I need to open a form to create a new related record to my original table. Once I hit submit, I want the original form that the UI action was initiated from to refresh so that my new item appears in the related list.
function openBidPop() {
var bid = new GlideModalForm('New Bid','x_ahho_fm_chargeba_bid_matrix',someCallBack());
bid.addParm('sysparm_request',g_form.getUniqueValue());
bid.render();
}
function someCallBack() {
}
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2016 09:33 AM
I was able to get my desired result by using the .setCompletionCallback method and then calling g_form.save() from the function.
Thanks
function openBidPop() {
var bid = new GlideModalForm('New Bid','x_ahho_fm_chargeba_bid_matrix');
bid.addParm('sysparm_request',g_form.getUniqueValue());
bid.render();
bid.setCompletionCallback(refreshForm);
}
function refreshForm() {
g_form.save();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2016 08:21 AM
As per the documentation, the call back function is The function to call after the form has been submitted and processed on the server
In your case you would just need to refresh the page in order to get (in the original form) the related list updated with the new inserted record via GlideModalForm.
You basically need the below code in your someCallBack() function:
function someCallBack(){
window.location.reload(true);
}
I hope this helps.
Best Regards,
Loris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2016 08:45 AM
Hi, thanks, but when I add that, I'm getting an error TypeError: Cannot read property 'location' of null(…)
This is a scoped app, don't know if that has anything to do with this or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2016 09:33 AM
I was able to get my desired result by using the .setCompletionCallback method and then calling g_form.save() from the function.
Thanks
function openBidPop() {
var bid = new GlideModalForm('New Bid','x_ahho_fm_chargeba_bid_matrix');
bid.addParm('sysparm_request',g_form.getUniqueValue());
bid.render();
bid.setCompletionCallback(refreshForm);
}
function refreshForm() {
g_form.save();
}