cancel
Showing results for 
Search instead for 
Did you mean: 

UOMs on Item (height/width unit1) invalid

Former Member
0 Kudos
96

Hi Everybody

I'm trying to duplicate an inventory item by saving the xml for the existing item and retrieving it back into a new object. My code seems to be working, EXCEPT for this message: [OITM.SHght1Unit] , 'The connected value '0' was not found in table Length Units'.

The saved XML has a value of zero, though, and so does the oItem object that generated the XML Zero is invalid in the OWGT table, but that IS the value in a retrieved item object. When I replace the zero with a 1 (for testing, that's obviously not the solution), that message goes away, but I get a similar message about OrdrIntrvl (OCYC), which also won't allow zeros, even though that's what's in the existing object.

Here's the code:

            tempXML = System.IO.Path.GetTempFileName()

            'retrieve template item object's xml into string
            itemObjectXML = zTmpltItm.GetAsXML

            'replace the template item code with the new one
            itemObjectXML = Replace(itemObjectXML, String.Format(ItemCodeXML, zTmpltItm.ItemCode), _
                            String.Format(ItemCodeXML, zNewCode))

            'replace the template item name with the new one
            itemObjectXML = Replace(itemObjectXML, String.Format(ItemNameXML, zTmpltItm.ItemName), _
                String.Format(ItemNameXML, zNewName))

            'Desperate attempt to fix Hght1Unit error
            itemObjectXML = Replace(itemObjectXML, String.Format(HeightXML, 1), _
                            String.Format(HeightXML, 1))
            itemObjectXML = Replace(itemObjectXML, String.Format(HeightXML, 2), _
                String.Format(HeightXML, 2))


            'save the template to disk
            sw = New System.IO.StreamWriter(tempXML, False)
            sw.WriteLine(itemObjectXML)
            sw.Close()

            'retrieve the new item's xml into a new item object for adding to the DB
            'zTmpltItm.SaveXML(tempXML)
            oNewItem = oCompany.GetBusinessObjectFromXML(tempXML, 0)

            retval = oNewItem.Add
            If retval <> 0 Then
                continue = False

Any Ideas? - Thanks

Problem solved by adding this line of code at the top:

oCompany.XmlExportType=et_ExportImportMode

Message was edited by:

John Chadwick

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

See text for solution. B1 support provided it