Getting This object has been modified, please refresh and try again error

I have a need go to prevent a workflow from being approved if there are mandatory attributes values missing from an ECO. I wrote a PX with the “Approve for Workflow” PRE event to advance the workflow (removed the auto-promote) with code. If it fails, I throw an exception to show the user the error. If all is well, the workflow would advance, and I was hoping it would move forward with the approval process. However, I was receiving a “This object has been modified, please refresh and try again error” error, preventing the approval to take place.

Below is the code, any help would be greatly appreciated. 

// Disable all warning messages including one not all approval has been done

IStatus [] sts = null;
sts = workflow.getStates(StatusConstants.TYPE_REVIEW);
IStatus release = sts[1];  // This is the status I want to advance to

// TRY/CATCH block to retrieve more detailed message
try {
     ECO.changeStatus(release, false, “”, true, true, null, null, null, false);
} catch (APIException ae) {
     throw new Exception (“ERROR……);

Add Comment
5 Answer(s)

Mmmm…I’m pretty sure you can’t mix those two in a single script.  Regardless of whether or not the ECO had the mandatory attributes filled in or not, I’m very certain Agile would have bumped the object version up since Agile will log that your script ran to the history tab of that eco.  Therefore, when you then try to update the state, Agile’s trying to work off of an older version of the same ECO.  
You can prove this by adding int obj_versionX = eco.objectVersion() or adding Boolean up_to_date = eco.isUpToDate() checks to your script.  

Try adding the line eco.refresh() before the session.disableAllWarning(); line and see if that works.

Nonetheless, I’ve read about bugs involved that make Agile throw the “This object has been modified” error, so if none the above tricks work for you, you may be facing something more complicated and will have to try different options like a POST event.

Agile Angel Answered on September 10, 2018.

Besides, on a PRE event, when Agile runs the script before the action actually happens at the database level, Agile hasn’t actually added the last approver’s signature to the ECO officially, so any script to release or change status should fail (because Agile knows that the person hasn’t yet approved).

on September 10, 2018.

Good point Matt but having the session.disableAllWarnings(); statement allowed the workflow to advance. However after the PX ends, and the system tries to approve, the system throws the error, not the PX.

on September 10, 2018.

Oh, that makes sense then.  Again, because it’s a PRE event, Agile runs the entire script and then only afterwards executes the PX action (in your case, Approve for Workflow).  If eco.refersh() doesn’t work for you then consider the other option in my post below.

on September 11, 2018.
Add Comment

Matt is right about trying to do any modifications to the change in a pre-event. You can’t. The system does not refresh after calling the pre-event so it has an old copy of the ECO.

Agile Angel Answered on September 10, 2018.

How about letting auto-promote do its thing instead of your px doing the change status?

on September 10, 2018.

We have it currently to auto-promote. The issue we are having is that if there are missing values, the approval will be completed but the status will not advance. Since an error does not pop up telling the users that is a problem, they sometimes don’t realize that the status did not change. The history tab indicates the problem but that can be easily overlooked. This is the issue we are trying to solve. Any other suggestion would be appreciated.

on September 11, 2018.
Add Comment

The main alternative here that I can think of is a POST event.  Upon ECO approval, and after your other PX has already blocked any signature from being registered when there’s missing fields on the ECO, write a different PX that will conduct a few checks (such as eco.audit(), missing fields, all-approve, etc.), then change the workflow.  Turn off auto-promote and just let your PX do the heavy lifting.  You can trigger this by ‘Approve for Workflow’ or even as a scheduled event w/ Query, among other options.  

I empathize with you too – failed auto-promote messages don’t tell a user what was missing until someone goes in and manually tries to change the status.

Agile Angel Answered on September 11, 2018.
Add Comment


Why ain’t you using a pre subscriber to check the mandatory fields are filled in or not and accordingly throw the error, thereby stopping the auto promote of the ECO to the next status ? If the validation is successful then anyhow the Agile autopromote will automatically move it to next status. Do not explicitly use changeStatus() method from within the handler of your pre-subscriber.

Agile Professional Answered on September 11, 2018.
Add Comment

Thank you everyone for your help. I will go forward with validation only in the PRE event and not advance the status.

Agile User Answered on September 12, 2018.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.