This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SUPPORT Q&A - Manual Promote Error in Lifecycle Transition Pre Method ( "An Item with the same key has already added").

Myint - Monday, May 6, 2013 10:36 PM:

 My requirement is once the "Part" is promoted from "Review" to "Released" state,  I want to set a property "pre_state" to "string.empty". 

So, I wrote a method shown the following;  and attach this method to the Part's Lifecycle Transition using "Pre".

But , I got the error "An Item with the same key has already added" when i promote a Part.

 

---------

Innovator tmpInn = this.getInnovator();

Item myAct

= this.newItem(this.getType(),"get");

myAct

.setID(this.getID());

myAct

.setAttribute("select","state,pre_state");

myAct

= myAct.apply();

myAct

.setAction("promoteItem");

myAct

.setProperty("state","Released");

myAct

.setProperty("pre_state", "");

Item l_last

= myAct.apply();

 

 

 

return 

 

 

this;

 

 

----------

 



vasant - Friday, May 10, 2013 2:57 AM:

Hi There,

Please use below code to get rid from error. Its due to you are trying to promote the Item again.

 

Innovator tmpInn = this.getInnovator();

Item myAct= this.newItem(this.getType(),"get");

myAct.setID(this.getID());

myAct.setAttribute("select","state,pre_state");

myAct= myAct.apply(); 

myAct.setAction("edit");

//myAct.setProperty("state","Released");

myAct.setProperty("pre_state", "");

Item l_last= myAct.apply();

return this;

Thanks- Vasant PADHIYAR