Page 1 of 2

Difference between nuActionSave and the Save in the action bar

Posted: Thu Aug 07, 2025 5:08 pm
by yvesf
Hello,

I initially believed that nuActionSave() was equivalent to clicking the save button in the action bar. However, its behavior appears to be different, particularly when it comes to retrieving the RecordId() afterward.

Case 1: If I save manually using the action bar and then call RecordId(), I correctly get the ID of the saved record.

Case 2: If I trigger nuActionSave() from a custom button and then try to retrieve the record ID, it returns nothing.

Could you please explain why this difference occurs? Also, what would be the proper way to retrieve the saved record’s ID after using nuActionSave()?

Thank you,
Yves

Re: Difference between nuActionSave and the Save in the action bar

Posted: Thu Aug 07, 2025 10:24 pm
by kev1n
Hi,

The record ID is shown for me:

Code: Select all

nuAddActionButton(
  'Run', 
  'Save Test', 
  'nuSaveAction()', 
).css('color','green');


function nuAfterSave() {
  alert('Record ID: ' + nuRecordId());
}


Re: Difference between nuActionSave and the Save in the action bar

Posted: Mon Aug 11, 2025 7:13 am
by yvesf
Hello Kev1n,

My nuSaveAction(true) is on a custom button in the edit form—not in the Action Bar.
When the save runs from that button, nuAfterSave() doesn’t fire as it fires with nuSaveAction() as opposed to nuSaveAction(true).
I use the true option as I need to close the popup at that moment.
Maybe just use nuSaveAction() without the true option. Is there a way to close the popup with another nubuilder option or do I have to use a javascript option like window.close()

Thanks again for your help.
Best regards,

Yves

Re: Difference between nuActionSave and the Save in the action bar

Posted: Mon Aug 11, 2025 7:35 am
by kev1n
I’m not seeing this issue when using a button with an onclick event calling nuSaveAction();.

And in Custom Code:

Code: Select all

function nuAfterSave() {
   alert('nuAfterSave triggered!');
}
It’s possible that some other code or settings in your form or setup are preventing the event from triggering.

Re: Difference between nuActionSave and the Save in the action bar

Posted: Mon Aug 11, 2025 7:57 am
by yvesf
nuSaveAction(true) doesn't fire nuAfterSave() after additionnal tests as opposed to nuSaveAction().

Re: Difference between nuActionSave and the Save in the action bar

Posted: Mon Aug 11, 2025 8:12 am
by yvesf
Workaround :

Code: Select all

nuSaveAction();// to fire the nuAfterSave() function
nuSaveAction(true); // to close the popup
weird but very efficient

Yves

Re: Difference between nuActionSave and the Save in the action bar

Posted: Mon Aug 11, 2025 8:42 am
by kev1n
In nuUpdateData(), the form is closed if true is passed to nuSaveAction().

If you place
nuProcessAfterSave();
after the line nuFORM.edited = false;, then nuAfterSave() will also be executed.

Re: Difference between nuActionSave and the Save in the action bar

Posted: Mon Aug 11, 2025 10:09 am
by yvesf
Just made the change without any impact
nuajax.js
. Maybe I have to refresh smthg

Yves

Re: Difference between nuActionSave and the Save in the action bar

Posted: Mon Aug 11, 2025 10:11 am
by kev1n
Did you log out, then log back in to nuBuilder?

Re: Difference between nuActionSave and the Save in the action bar

Posted: Mon Aug 11, 2025 10:14 am
by yvesf
yes but no real result. I cannot restart the web server as I am hosted by cybermania