Page 1 of 1

Changing aproval status with velocity

Posted: Tue May 08, 2018 9:04 am
by Harou33
Hello all,

I wrote script, which should change requirements status. It works, but it only changes few items and after that I receive error like that:

Screenshot_1.png
Screenshot_1.png (10.77 KiB) Viewed 1272 times


So beceause of it I must run this script many times to finish job.

This is script:

Code: Select all

 
 #set($query="project.id:####### AND document.title:###### AND type:#########")
        #set($WIs=$trackerService.queryWorkItems($query, "id"))


        #foreach($wi in $WIs)                           
                #set($Approvals = $wi.getApprovals())

               #foreach($approval in $Approvals)         
             
                   #set($app = $approval.getStatus().getId()) 
                     #if($app == "approved")   
                       
                           ## $wi     
                           ## $approval
                            $transactionService.beginTx()
                            $approval.setStatus($wi.getProject().getApprovalStatusEnum().wrapOption("waiting"))
                            $wi.save();
                       $transactionService.commitTx()                   
                 
                       #end
               #end
        #end


Why I am not able to change everything by first time? What this error means?
Thanks for answers.

Re: Changing aproval status with velocity

Posted: Tue May 15, 2018 11:12 am
by Jürgen
Hello, Harou

I am not sure about this, but the exception is named "ResourceConflictException" and shows two revision numbers. I think one of them is the revision that you are changing, and the other is the latest of this work item.

I have seen this exception for example, when I accidentally changed the work item twice in parallel, in different browser windows. Saving the second one lead to the exception.

Maybe your script contains duplicate work item IDs or something like that.

Re: Changing aproval status with velocity

Posted: Wed May 16, 2018 12:00 pm
by RodneyVin
I believe Jürgen is on to something. Did you check your script for duplicate work, Harou33? I'd love to get to the bottom of this as I'm doing something very similar as well.