Item Master Data Import

mfoxmfox Member Posts: 4
Version Nav 6.0

I am trying to create a dataport to import update Items into the system. To keep it simple, I am uploading the "No.", "Description" and "Sales Unit Of Measure" Field.

To ensure validation on the Sales Unit of Measure, I have written the following code in the "onAfterImportRecord" Event:

VALIDATE("Sales Unit of Measure");
MODIFY;

Once I run this routine, I get the following error:

"The Item Unit of Measure Does Not Exist"

Now if I go into the Item Master Card, under the Invoicing Tab, The Sales Unit Of Measure shows "EACH", but when I click on the drop down the "Code Field" is empty. I have to click on that drop down key and select "EACH" from that menu.

What am I missing here????

Comments

  • SavatageSavatage Member Posts: 7,142
    The UOM is a lookup from another table - Item Unit Of Measure.
    So one thing you can do is check if the code exist and if it doesn't then INSERT it.
    Something Like Below.

    OnAfterImportRecord()
    IF "Item Unit Of Measure".GET(Item."No.", Item."Base Unit of Measure")
     THEN BEGIN
      MESSAGE('Item UOM Already Exists');
    END
      ELSE BEGIN
      "Item Unit Of Measure".Code := Item."Base Unit of Measure";
      "Item Unit Of Measure"."Item No." := Item."No.";
      "Item Unit Of Measure"."Qty. per Unit of Measure" := 1;
      "Item Unit Of Measure".INSERT(TRUE);
      Item."Purch. Unit of Measure" := Item."Base Unit of Measure";
      Item."Sales Unit of Measure" := Item."Base Unit of Measure";
    END;
    
  • mfoxmfox Member Posts: 4
    Thank you for your response I am new at this,

    Will I have to add the "Item Unit Of Measure" table to the dataport for the Variable Reference?
  • SavatageSavatage Member Posts: 7,142
    View->Globals

    Add

    Variable Name->ItemUOM ->Type "Record"->Subtype "Item Unit Of Measure"
    IF ItemUOM.GET(Item."No.", Item."Base Unit of Measure") <<or insert your vaiable names if you're using variables
    THEN BEGIN
      MESSAGE('Item UOM Already Exists');
    END
      ELSE BEGIN
      ItemUOM.Code := Item."Base Unit of Measure";
      ItemUOM."Item No." := Item."No.";
      ItemUOM."Qty. per Unit of Measure" := 1;
      ItemUOM.INSERT(TRUE);
    //I see your first post - you're omly paying attention to "Sales Unit Of Measure"
    //All three are important. In fact I think Base is the most important.
      Item."Purch. Unit of Measure" := Item."Base Unit of Measure";
      Item."Sales Unit of Measure" := Item."Base Unit of Measure";
    END;
    
  • mfoxmfox Member Posts: 4
    Excellent, worked like a charm.

    Thank you very much.
  • SavatageSavatage Member Posts: 7,142
    glad it worked for you.
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV 2009' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.