How to check whether gr.update() failed due to setAbortAction(true)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2013 08:51 AM
How to check whether update happened successfully or not?
I have created transform map, where I am updating multiple records in onBefore() script.
but meanwhile some BR written on same table aborts the update using setAbortAction(true).
I want these BRs to execute and abort incorrect data update. But problem is I can't find in transform map whether update happened or not.
I want to stop execution of further operations written in Transform Map if record did not updated.
Is there any way to find whether update using gr.update() did not happened? So I can display error message and stop further actions (updates) written in transform script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2013 01:06 AM
The GlideRecord has a function
that can be used for this.
isActionAborted()
Unfortunately there is no function to set an error description on the GlideRecord, but there is one on GlideElement. In a project where we had lots of integrations we established the convention that if you abort an operation you have to set the error on the GlideElement of the
field.
sys_id
Also when using the
function you have to be careful with the before Business Rules. Even if the action is in the end aborted all Business Rules that run on before are still executed. While no changes to the
setAbortAction
record are commited to the database you have to make sure that no before BR executes any changes to the database to other records. Out of the box there are some BR that fire events which run on before and I think should not fire in case of an aborted action.
current
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2013 02:18 AM
thank you !!!!!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2013 08:20 AM
The update() method in GlideRecord returns one of the following:
1) the sys_id of the record, if the update was successful
2) null, if the update was NOT successful
So you could do the following:
if (gr.update() == null) {
gs.addErrorMessage("the update failed!");
// maybe do other stuff
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2016 09:27 AM
thanks