Options

Solution Request for "The Sales Line already exists" in WS

joehjoeh Member Posts: 32
edited 2011-10-31 in NAV Three Tier
Hi Everyone,
I'm using NAV 2009 SP1 UK Edition. (CRONUS UK Ltd.) and the error is with Web Services

I have the code below which is used to create a sales order however it is not working and I recieve the following error:
Fatal error: Uncaught SoapFault exception: [a:Microsoft.Dynamics.Nav.Types.Exceptions.NavCSideException] The Sales Line already exists. Identification fields and values: Document Type='Order',Document No.='1115',Line No.='10000' in ****** Stack trace: #0 ********(301): SoapClient->__call('Update', Array) #1 *******(301): NTLMSoapClient->Update(Object(stdClass)) #2 {main} thrown in ********* on line 301

This is the code (php):
******


I know the code is correct and I have tried different ways such as Arrays and it has been the same problem, I'm very sure its a bug that I'm facing.

I would appreciate if anyone knows the solution to this problem

Kind Regards
Joeh Chan
Joeh Chan,
HostLive Limited

Comments

  • Options
    DenSterDenSter Member Posts: 8,304
    joeh wrote:
    I know the code is correct
    I like your optimism, but when your code generates errors that is not very realistic is it :mrgreen:

    Read the error message, it clearly says what is going on: "Sales Line already exists". Figure out what makes a sales line record unique. Analyze your code whether you are taking proper precautions not to insert records that already exist. Modify your code accordingly.
  • Options
    joehjoeh Member Posts: 32
    edited 2010-11-11
    Hi Daniel
    Thanks for your feedback

    The availability of fields via WSDL is limited and doesn't let you define a unique Line Order Number, and by my research it shows by design it auto-increments.

    The code I have shown above has been taken from another person who used it successfully with SP1 but another build. My code using Arrays (similar way) presented the same error thus why I tried different peoples code as I thought I may have been doing it wrong.

    When I realised that the two codes were providing the same error for me then I have then the assumption that the code is correct but the WS is working incorrectly.

    If I am wrong please point me towards the correct direction because I already had consideration for that and spent the last 9 hours (mixture of today and yesterday) trying from different angles.

    If you know a field which will let you define the Line number please let me know because there isn't one that I can see here:

    From Sales Order Page
    - <xsd:complexType name="Sales_Order_Line">
    - <xsd:sequence>
      <xsd:element minOccurs="0" maxOccurs="1" name="Key" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Type" type="tns:Type" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="No" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Cross_Reference_No" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="IC_Partner_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="IC_Partner_Ref_Type" type="tns:IC_Partner_Ref_Type" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="IC_Partner_Reference" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Variant_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Substitution_Available" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Purchasing_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Nonstock" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="VAT_Prod_Posting_Group" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Description" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Drop_Shipment" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Special_Order" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Return_Reason_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Location_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Bin_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Reserve" type="tns:Reserve" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Quantity" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Reserved_Quantity" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Unit_of_Measure_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Unit_of_Measure" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Unit_Cost_LCY" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="SalesPriceExist" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Unit_Price" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Line_Amount" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="SalesLineDiscExists" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Line_Discount_Percent" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Line_Discount_Amount" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Prepayment_Percent" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Prepmt_Line_Amount" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Prepmt_Amt_Inv" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Allow_Invoice_Disc" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Inv_Discount_Amount" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Qty_to_Ship" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Quantity_Shipped" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Qty_to_Invoice" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Quantity_Invoiced" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Prepmt_Amt_to_Deduct" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Prepmt_Amt_Deducted" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Allow_Item_Charge_Assignment" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Qty_to_Assign" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Qty_Assigned" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Requested_Delivery_Date" type="xsd:date" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Promised_Delivery_Date" type="xsd:date" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Planned_Delivery_Date" type="xsd:date" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Planned_Shipment_Date" type="xsd:date" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Shipment_Date" type="xsd:date" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Shipping_Agent_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Shipping_Agent_Service_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Shipping_Time" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Work_Type_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Whse_Outstanding_Qty_Base" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Outbound_Whse_Handling_Time" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Blanket_Order_No" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Blanket_Order_Line_No" type="xsd:int" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="FA_Posting_Date" type="xsd:date" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Depr_until_FA_Posting_Date" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Depreciation_Book_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Use_Duplication_List" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Duplicate_in_Depreciation_Book" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Appl_from_Item_Entry" type="xsd:int" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Appl_to_Item_Entry" type="xsd:int" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Shortcut_Dimension_1_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Shortcut_Dimension_2_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="ShortcutDimCode_x005B_3_x005D_" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="ShortcutDimCode_x005B_4_x005D_" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="ShortcutDimCode_x005B_5_x005D_" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="ShortcutDimCode_x005B_6_x005D_" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="ShortcutDimCode_x005B_7_x005D_" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="ShortcutDimCode_x005B_8_x005D_" type="xsd:string" /> 
      </xsd:sequence>
    

    Or Here
    From Sales Line Page
    - <xsd:complexType name="Sales_Line">
    - <xsd:sequence>
      <xsd:element minOccurs="0" maxOccurs="1" name="Key" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Type" type="tns:Type" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="No" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Cross_Reference_No" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="IC_Partner_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="IC_Partner_Ref_Type" type="tns:IC_Partner_Ref_Type" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="IC_Partner_Reference" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Variant_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Substitution_Available" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Purchasing_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Nonstock" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="VAT_Prod_Posting_Group" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Description" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Drop_Shipment" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Special_Order" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Return_Reason_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Location_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Bin_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Reserve" type="tns:Reserve" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Quantity" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Reserved_Quantity" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Unit_of_Measure_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Unit_of_Measure" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Unit_Cost_LCY" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="SalesPriceExist" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Unit_Price" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Line_Amount" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="SalesLineDiscExists" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Line_Discount_Percent" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Line_Discount_Amount" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Prepayment_Percent" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Prepmt_Line_Amount" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Prepmt_Amt_Inv" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Allow_Invoice_Disc" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Inv_Discount_Amount" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Qty_to_Ship" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Quantity_Shipped" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Qty_to_Invoice" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Quantity_Invoiced" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Prepmt_Amt_to_Deduct" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Prepmt_Amt_Deducted" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Allow_Item_Charge_Assignment" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Qty_to_Assign" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Qty_Assigned" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Requested_Delivery_Date" type="xsd:date" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Promised_Delivery_Date" type="xsd:date" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Planned_Delivery_Date" type="xsd:date" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Planned_Shipment_Date" type="xsd:date" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Shipment_Date" type="xsd:date" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Shipping_Agent_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Shipping_Agent_Service_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Shipping_Time" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Work_Type_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Whse_Outstanding_Qty_Base" type="xsd:decimal" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Outbound_Whse_Handling_Time" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Blanket_Order_No" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Blanket_Order_Line_No" type="xsd:int" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="FA_Posting_Date" type="xsd:date" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Depr_until_FA_Posting_Date" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Depreciation_Book_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Use_Duplication_List" type="xsd:boolean" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Duplicate_in_Depreciation_Book" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Appl_from_Item_Entry" type="xsd:int" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Appl_to_Item_Entry" type="xsd:int" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Shortcut_Dimension_1_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="Shortcut_Dimension_2_Code" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="ShortcutDimCode_x005B_3_x005D_" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="ShortcutDimCode_x005B_4_x005D_" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="ShortcutDimCode_x005B_5_x005D_" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="ShortcutDimCode_x005B_6_x005D_" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="ShortcutDimCode_x005B_7_x005D_" type="xsd:string" /> 
      <xsd:element minOccurs="0" maxOccurs="1" name="ShortcutDimCode_x005B_8_x005D_" type="xsd:string" /> 
      </xsd:sequence>
    

    BTW: If you haven't noticed the code I posted in my previous post generates a new sales order and updates the details accordingly.

    Thanks
    Joeh
    Joeh Chan,
    HostLive Limited
  • Options
    joehjoeh Member Posts: 32
    ttt
    Joeh Chan,
    HostLive Limited
  • Options
    DenSterDenSter Member Posts: 8,304
  • Options
    joehjoeh Member Posts: 32
    To the top

    -- Any thoughts Daniel?
    Joeh Chan,
    HostLive Limited
  • Options
    DenSterDenSter Member Posts: 8,304
    Yeah I have a lot of thoughts. You edited the reply that you posted earlier, but you were actually quite rude. It's funny how you come in here asking for help, yet you get rude at the first person that takes the time to help you. Just like your assertion that there's nothing wrong with your code, even though it generates errors, and the fact that you bump a post after 15 minutes, that tells me a lot about you.

    I have better things to do than tell you how to do your job. Good luck finding the answers though.
  • Options
    joehjoeh Member Posts: 32
    I don't want to argue about it really and I'm not that type of person but seriously your initial post was not beneficial to say the least.

    The only thing I said that I edited out was "I know how to read and thanks for telling me something I already knew" so there is no need to be too sensitive; verily it was encouraged about your arrogant answer of "I like your optimism, but when your code generates errors that is not very realistic is it" when it shows you didn't take the effort to read the code. If you've entered a post for non-constructive criticism don't expect a shy face, you can easily raise your post count else where.

    Although you don't know of my background and knowledge doesn't justify a reply of "Read the error message.. ".

    If you were really replying to help then you may have considered to read the code that I had put there (which was for a purpose) and maybe you would have realised what was trying to be achieved.

    Just to correct your statement: "and the fact that you bump a post after 15 minutes, that tells me a lot about you", the topic had passed under several other posts and I was just trying to maintain its visibility.

    I don't want to start on the wrong foot in this forum but consider yourself in my position, although I'm new here (which doesn't mean I'm new to programming etc.) I don't really expect that when I ask for help I'm told to basically work it out for myself (even though your answer was incorrect in this instance).
    Joeh Chan,
    HostLive Limited
  • Options
    dhakshnamoorthydhakshnamoorthy Member Posts: 19
    What is this Error ? When I put an entry in Sales quote I am getting this error.

    The BOM Quotation already exists, Identification fields and values:
    quotation id='1009', document type='quote', line no.='10000',type='item',parent item no.='1000'

    How to solve this one.
  • Options
    joehjoeh Member Posts: 32
    What is this Error ? When I put an entry in Sales quote I am getting this error.

    The BOM Quotation already exists, Identification fields and values:
    quotation id='1009', document type='quote', line no.='10000',type='item',parent item no.='1000'

    How to solve this one.

    You need to first:
    1.Create empty sales quote header and store key.
    2.Use the Key to then populate the already created sales quote header + insert blank sales quote lines (with Type => Item ) and store new line keys.
    3. Use a key per line to update the new lines with quantities & item codes.
    Joeh Chan,
    HostLive Limited
Sign In or Register to comment.