- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 03:16 AM
Hello,
We have created a custom Save button on a scoped application for a table. The code for the button is given below. The Save button is conditionally visible, which is why we created it instead of using the out-of-box (OOB) Save button (which saves a new record and redirects back to itself). Could you please review the code to ensure it follows best practices? If not, please provide recommendations for improvement.
current.update();
action.setRedirectURL(current);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 11:30 AM
Hello @Khalid9030 ,
current.insert() should be inserted only inside if loop where you will check if given record isNewRecord() else current.update() should run.
For Example -
if(current.isNewRecord()){ //New Record which is not saved/created/inserted into the table yet.
current.insert();
}else{
current.update();
}
Let me know if it helps.
Thanks,
Shubham

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 04:34 AM
@Khalid9030 I don't see any issues with your code here. It is following the standard practice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 05:12 AM
Hello @Khalid9030 ,
Although the code looks good, but you can ADD COMMENTS to score more in terms of code readability matrix.
Mark this as Accepted Solution/Helpful if above info. helps in any way and help in closing this thread.
Regards,
Shubham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 05:21 AM
Thanks for your reply.
In OOB save button i just found curret.insert(); ,
May i know which one should i use current.update() or curret.insert(); in my custom Save button

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 05:23 AM
@Khalid9030 If your UI Action updates the existing record then you should use current.update(). If your UI Action creates a new record then you should use current.insert();
Hope this helps.