OptionString in XML

I try to create a sales order using a standard web service. It works fine with items, but I cannot create sales lines that uses G/L Accounts. I write this in XML:

<Sales_Order_Line>
<Type>G/L Account</Type>
<No>1485</No>
<Description>Description</Description>
<Quantity>1</Quantity>
<Unit_Price>59</Unit_Price>
</Sales_Order_Line>

I get an error saying that the optionString does not exist. If I change the "Type" to "Item", it works fine.

How do I write "G/L Account" in XML?

Best Answers

  • MortenSteengaardMortenSteengaard Posts: 42
    Accepted Answer
    Now I have read all the sales lines using my page to export it and show it in my browser. It turns out that the "G/L Account" optionString is shown as "G_L_Account". And when I use that value as input, everything works fine.

    It does not work with the numeric value.
    It does not work in you local NAV language (for me it is Danish).
    It works if you change all spaces and special characters to underscore.

    I didn't expect that, since the normal text fields in XML CAN contain spaces and '/'.

    Thank you very much for your help.

Answers

  • azharsaeedkhanazharsaeedkhan Posts: 5Member
    To get better idea of the XMLPorts just try to export the "G/L Account" type "Sales Line" in an XML format. You will get better understanding, using this approach.
    You can also import the same file back to the system. So just edit it, put in the values and import it back :)
  • MortenSteengaardMortenSteengaard Posts: 42Member
    Hi Azharsaeedkhan.

    I use a copy of page 42 as a web service.

    If I create a new XMLport with sales lines, I can easily import new lines like this:

    <?xml version="1.0" encoding="UTF-16" standalone="no"?>
    <root>
    <salesLine>
    <DocumentType>Order</DocumentType>
    <DocumentNo.>1019</DocumentNo.>
    <LineNo.>50000</LineNo.>
    <Type>G/L Account</Type>
    <No.>1009</No.>
    <Description>Sale of extra stuff</Description>
    <Quantity>200</Quantity>
    <UnitPrice>23,00</UnitPrice>
    </salesLine>
    </root>

    So XMLports works fine. The problem is that my page won't accept the value "G/L Account" in the XML from the web. I use Widzler to enter the XML code in my browser, when I test this.
  • azharsaeedkhanazharsaeedkhan Posts: 5Member
    Yes, in that case you should try numeric value for optionstring.
  • MortenSteengaardMortenSteengaard Posts: 42Member
    Accepted Answer
    Now I have read all the sales lines using my page to export it and show it in my browser. It turns out that the "G/L Account" optionString is shown as "G_L_Account". And when I use that value as input, everything works fine.

    It does not work with the numeric value.
    It does not work in you local NAV language (for me it is Danish).
    It works if you change all spaces and special characters to underscore.

    I didn't expect that, since the normal text fields in XML CAN contain spaces and '/'.

    Thank you very much for your help.
Sign In or Register to comment.