Xrec equals Rec when calling Validate from XMLPort

bob_upbob_up Member Posts: 155
I am inserting records into the sales line table using an XMLPort in NAV2013 R2.

I use the following statement to assign the item code, which is read into the SKU text variable.
"Sales Line".Type := "Sales Line".Type::Item;
"Sales Line".VALIDATE("No.",SKU);
However this fails to execute the following code in the No. - OnValidate() trigger on the "Sales Line" table.
IF "No." <> xRec."No." THEN BEGIN
  IF Type = Type::Item THEN
    IF (Quantity <> 0) AND ItemExists(xRec."No.") THEN BEGIN
      ReserveSalesLine.VerifyChange(Rec,xRec);
      WhseValidateSourceLine.SalesLineVerifyChange(Rec,xRec);
    END;
  GetDefaultBin;
  AutoAsmToOrder;
  DeleteItemChargeAssgnt("Document Type","Document No.","Line No.");
  IF Type = Type::"Charge (Item)" THEN
    DeleteChargeChargeAssgnt("Document Type","Document No.","Line No.");
END;
This is because Xrec."No." is the same as Rec."No." when the trigger is called from an XMLport.

Is there someway around this?

Comments

  • lvanvugtlvanvugt Member Posts: 774
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • bob_upbob_up Member Posts: 155
    Thank you Luc. That has got me "unstuck".

    However, I am left with one problem.

    The unit price on the sales line cannot be read directly from the import file. It will need to be calculated. This is because the import file layout includes a total line amount and a quantity but not a unit price. E.g. a quantity of 2 and a line amount of 200 needs to generate a unit price of 100 on the sales line table. The import file layout is not under my control.

    So I will need to calculate the unit price and assign it to the "Sales Line"."Unit Price" field. I will then need the validation code on the "Unit Price" field to be executed (to correctly update the various line values) but I cant see how to do this without hitting my original problem again.
  • lvanvugtlvanvugt Member Posts: 774
    I assumed you would be browsing through some more of my posts on validation. Read this one: Validating Data #2: Using VALIDATE - c'tnd.
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • bob_upbob_up Member Posts: 155
    I did browse your other posts ;-)
    However, this one didn't seem to offer any help with my problem.
    I thought your original post demonstrated that when you use VALIDATE in an XMLPort in the way shown in Example 1 then xRec and Rec will be the same.
  • lvanvugtlvanvugt Member Posts: 774
    bob_up wrote:
    I did browse your other posts ;-)
    :thumbsup:
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
Sign In or Register to comment.