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 - same exact AML response but different results

esteimle - Thursday, January 12, 2012 10:17 AM:

So I took over the onGet function for my custom BOM.   I was trying to find away to return multiple items when I got stuck on this error.   I can return, according to NASH, the same exact AML result generated two different ways.  One way works and the other doesn't.    The first way I try to use the built in item methods to create the results, this does not show the CIP part in the BOM list in innovator:

 

//these two items are what is going to get returned

    Item res = this.getInnovator().newResult("");

    XmlElement resultNd = (XmlElement) res.dom.SelectSingleNode("/*/*/*");

 

    //get the source ID

    XmlNode xSourceId = dom.SelectSingleNode("/Item/source_id/text()");

    string sSourceId = xSourceId.Value;

 

    Item bom = this.newItem("CIP Part BOM");

    bom.setType("CIP Part BOM");

    bom.setID("0FBE827DE1394675A68C13FA13C67F9C");

    bom.apply();

    bom.removeAttribute("isNew");

    bom.removeAttribute("isTemp");

 

 //create a fake CIP_PART here

    Item res5 = this.newItem("CIP_PART");

             string newid = getNewID();

             res5.setID("A6F68F1E57C3432AA07E598F2468FFE2");

             res5 = res5.apply();

             res5.setProperty("part_number", "CT-ERIC-TEST");

             res5.setProperty("manf_part_number", "00-333-0000");

             res5.setProperty("manufacturer", "ACME");

             res5.setProperty("description", "Road Runner Bait");

 

    bom.setRelatedItem(res5);

 

    resultNd.AppendChild(resultNd.OwnerDocument.ImportNode(bom.node, true));

/*

    StreamWriter sw = null;

    sw = File.CreateText("C:/Program Files (x86)/Aras/Innovator/Innovator/Server/temp/loge.txt");

    sw.WriteLine("--- BEGIN LOG ---");

    sw.WriteLine("bom: {0}", xNode);

 

    sw.Flush();

    sw.Close();

    */

    return bom;

 

 

Now if on the other hand I generate the result using  loadAML, everything works fine.

 

    Item wtf = this.newItem("CIP Part BOM");

 

string aml = "<Result>"

+"<Item type =" CIP Part BOM " id =" 0FBE827DE1394675A68C13FA13C67F9C " >"

+"<related_id>"

+"<Item type =" CIP_PART " typeId =" 56D225FB95344D5C87128E28A366C307 " id =" A6F68F1E57C3432AA07E598F2468FFE2 " >"

+"<part_number>CT-ERIC-TEST</part_number>"

+"<manf_part_number>00-333-0000</manf_part_number>"//-

+"<manufacturer>ACME</manufacturer>"

+"<description>Road Runner Bait</description>"

+"</Item>"

+"</related_id>"

+"</Item>"

+"</Result>";

 

 wtf.loadAML(aml);

 return wtf;

 

Both of these methods of mine return the same AML response:

-<SOAP-ENV:Envelope>

-<SOAP-ENV:Body>

-<Result>

-<Item type =" CIP Part BOM " id =" 0FBE827DE1394675A68C13FA13C67F9C " >

-<related_id>

-<Item type =" CIP_PART " typeId =" 56D225FB95344D5C87128E28A366C307 " id =" A6F68F1E57C3432AA07E598F2468FFE2 " >

 <part_number>CT-ERIC-TEST</part_number>

 <manf_part_number>00-333-0000</manf_part_number>

 <manufacturer>ACME</manufacturer>

 <description>Road Runner Bait</description>

 </Item>

 </related_id>

 </Item>

 </Result>

 </SOAP-ENV:Body>

 </SOAP-ENV:Envelope>

I even diff'd the two responses to make sure I wasn't missing something.   Well I'm sure I'm missing something because they operate differently, but I can't tell what.

 

 

 



esteimle - Thursday, January 12, 2012 10:26 AM:

Ah needed to return res; not return bom; for the first method.  After that change it works...