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

DEVELOPERS FORUM - Error: Item has already been added. Key in Dictionary. "Key being added"

sherenegladysj - Wednesday, November 18, 2009 7:11 AM:

Hello all,

Once I route a Rleased Part as Change Affected Item through an ECO with Interchangeable set. In the Prepare Change Activity, I'm getting the error "Item has already been added. Key in Dictionary. "Key being added"

I have added one tab under Part as "Expense" if there are two line items I'm getting error while creating Rev "B". If there is one line item I'm not getting any error.

I feel that while trying to create version of an ItemType it's giving error. It is throwing error in "Affected Item handling" method. Below is the code. I have no clue how the below code works & what is the error?

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

// Version affected_id items For action=Change And interchangeable=1

if

 

 

 

 

 

 

(affItemRel.getItemsByXPath(rootXPath+"Item[@type='Affected Item'][action='Change'][interchangeable='1']").getItemCount() > 0)

{

 

 

Item z

= this.newItem("SQL", "SQL PROCESS");

z

 

.setProperty("name", "PE_GetAffectedItemHandlingOrder");

z

.setProperty("PROCESS", "CALL");

z

.setProperty("ARG1", this.getID());

z

.setProperty("TYPE", affItemRelType);

z

= z.apply();

 

 

for (int i=0; i<z.getItemCount(); i++)

 

 

{

String thisId

= z.getItemByIndex(i).getProperty("obj_affected_item_id",".");

Item thisItem

= affItemRel.getItemsByXPath(rootXPath+"Item[@type='Affected Item'][action='Change'][interchangeable='1'][../../@id='"+thisId+"']");

 

 

if (thisItem.getItemCount() == 1)

 

 

{

Item tempItem

= this.newItem();

tempItem

.loadAML("<Item typeId='"+thisItem.getPropertyItem"affected_id").getProperty("itemtype", "")+"' action='version'/>");

tempItem

.setID(thisItem.getProperty("affected_id","NON_EXISTING"));

tempItem

= tempItem.apply(); (I am getting error here...)

 

 

if (tempItem.isError()) return inn.newError("Affected Item Error: Error versioning item: "+thisItem.getPropertyItem("affected_id").getProperty"keyed_name","unknown"));

tempItem

= tempItem.apply("unlock");

 

 

if (tempItem.isError()) return inn.newError("Affected Item Error: Error unlocking Item: "+thisItem.getPropertyItem("affected_id").getProperty"keyed_name","unknown"));

affItem

= this.newItem("Affected Item","edit");

affItem

.setID(thisItem.getID());

affItem

.setAttribute("serverEvents","0");

affItem

.setAttribute("doGetItem","0");

affItem

.setProperty("new_item_id",tempItem.getID());

affItem

= affItem.apply();

 

 

if (affItem.isError()) return inn.newError("Affected Item Error: Error editing Affected Item: "+thisItem.getPropertyItem("affected_id").getProperty("keyed_name","unknown"));

 

 

}

 

 

 

}

}

 

 

It would be great, if I can get help from anyone...

 

Thanks & Regards,

Sherene