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 - Not able to assign a string value to the string type attributes of a PR ITEM Type

jacobandrews - Monday, July 15, 2013 2:52 AM:

string sattr1 = "PR-10005"

string sattr3 = "finalchange"

 

 

 Item pr1 = MyInnovator.newItem("PR", "add");

                        bRes = pr1.isError();

                        pr1.setProperty("item_number", sattr1);

                        pr1.setProperty("title", sattr3); /// Without this line of code , the PR gets created...

                        pr1.apply();

 

Please suggest what is wrong in the method of setting the property attribute.

Even if I use pr1.setPropertyAttribute("String","title",sattr3); it does not work

 

 



zahar - Monday, July 15, 2013 11:16 AM:

try to return error from  pr1.apply() when you trying to set title



Brian - Monday, July 15, 2013 8:51 PM:

Hi Jacob,

Not sure what is wrong with your code.

It works for me.

This code executed as an action creates the PR with the "finalchange" title as expected.

 

Innovator inn = this.getInnovator();

string sattr1 = "PR-10005";

string sattr3 = "finalchange";

 

Item pr1 = inn.newItem("PR", "add");

pr1.setProperty("item_number",sattr1);

pr1.setProperty("title",sattr3);

pr1 = pr1.apply();

 

if ( pr1.isError() ){

return inn.newError(pr1.getErrorString());

}

return this;

 

I suggest using the "pr1 = pr1.apply();" syntax then you can check and return the error if there is one.

Hope this helps.

Brian.



jacobandrews - Wednesday, July 17, 2013 4:42 AM:

Thanks for the reply.

 

its displays the error "the PR already exists"...

 

 

Its displays the same message even if a PR no that does not exist id given as input for creation of the PR.



jacobandrews - Friday, July 19, 2013 2:25 AM:

Hi Brian,

 

I changed the code like this... Its now works in this fashion...

Now I am setting the affected item attribute at the end ... First I set all the string values....

 Item pr1 = MyInnovator.newItem("PR", "add");                       

                        pr1.setProperty("item_number", sattr1);                       

                        pr1.setProperty("title", "tushar");

                        pr1.setProperty("environment", "tushar machine ssghosig ");

                        pr1.setProperty("events", "seq121212121");

                        pr1.setProperty("description", " desc1  desc sldjflksgflasdnflsanlsnfd slfnlsfnslnf descropr[trtkn");

                        pr1.setProperty("verification", " verification is required for the below nedds");

 

                        // Set the Affected Item property by getting the tag of the item and attaching it to the item

                        Item qryItem = MyInnovator.newItem("Part", "get");

                        qryItem.setAttribute("select", "item_number");

                        qryItem.setProperty("item_number", sattr2);

                        qryItem.setPropertyCondition("type", "eq");

                        Item results = qryItem.apply();

                        Item pt1 = results.getItemByIndex(0);

                        pr1.setPropertyItem("affected_item", pt1);

                        Item check1 = pr1.apply();