Changing aproval status with velocity

Description
Harou33
Posts: 10
Joined: Wed Apr 04, 2018 10:40 am

Changing aproval status with velocity

Postby Harou33 » Tue May 08, 2018 9:04 am

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 1214 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.

Jürgen
Posts: 43
Joined: Tue Sep 12, 2017 1:02 pm

Re: Changing aproval status with velocity

Postby Jürgen » Tue May 15, 2018 11:12 am

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.

RodneyVin
Posts: 1
Joined: Wed May 09, 2018 9:23 am

Re: Changing aproval status with velocity

Postby RodneyVin » Wed May 16, 2018 12:00 pm

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.


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 16 guests