How copy fields from a table to a another one automatically

Mic28Mic28 Member Posts: 13
Hi everybody; I have two new fields (are "down" fields) on Vendor table, and I want to copy the content from these fields to the same Item table fields automatically, for not have to go product by product. I would be comparing the "Vendor No." for example. I think it can be done through a report that launch an automated process. Can anyone explain me how can I do it, please?.
Thanks in advance.

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Can you use flowfields for this?

    Maybe it is a good idea to start reading the Application Designer guide or purchase David Studebakers book.

    http://www.packtpub.com/Microsoft-.NET- ... ision/book
  • BeliasBelias Member Posts: 2,998
    what are "down" fields? :-k
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Mic28Mic28 Member Posts: 13
    Thanks both for reply; I prefer don't use flowfields because, in future, it always becames a problem (if you want to create "keys" with these fields, for example).
    "Down" fields are expand fields, I mean, it looks for a table and you choose the code (like an option field), sorry. Any idea please?.
    Thanks.
  • BeliasBelias Member Posts: 2,998
    as Mark said, you should study before implementing anything...it's clear that you don't know what is a lookup field, or you explained really bad or i understood really bad :) (e.g. i think you want to have a field like shipment code on sales order). This is a basic knowledge to have.
    If you really want to do this, just check the field i said, take a look at his properties and make your considerations.
    hint: table relation property
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    You cannot create a tablerelation to a non-primairy key field.

    Your new fields should refer to a code table like payment terms, country/region or something alike.
  • Mic28Mic28 Member Posts: 13
    Thanks everybody for reply. It's clear that I've explained very bad, sorry for it. I know that I can use flowfields, but I don't want to do it because if I do that I'll can't change the field in product label, it always will copy from vendor. I'll try to explain me with detail.
    The two new fields in vendor table are already informed. I've created the same fields on Item table that now are empty. On "Vendor Nº." trigger from Item table I've created the instrucction:
    Field1:=vendortable.Field1;
    Field2:=vendortable.Field2;
    Then, when I create a new item it gets the content from filed1 form vendor table. It runs me well. But, what about the items that have also been created?, I should be inform all the items one by one?. So I need to launch an automatic process that fill that fields automatically, I suppose filtering by vendor number. Somethig like:
    If vendor n=12525 then field1:='example';
    I hove I've explained well; sorry for confusion.
    Thanks.
  • SavatageSavatage Member Posts: 7,142
    Is
    Field1:=vendortable.Field1;
    Field2:=vendortable.Field2;

    on the Onvalidate trigger of "Vendor No" in the item table? not form.

    If so and you have that working, it appears you want to fill in all the old items with an update report.

    Dataitem->Item
    Global Variable -> Vendor=Record=Vendor
    OnAfterGetRecord()
    Clear(Field1);
    Clear(Field2);
    If Vendor.GET("Vendor No.") then begin
     Field1:=vendor.Field1;
     Field2:=vendor.Field2; 
     Modify;
    End;
    

    When you run the report you can filter on when these fields are blank so just those get updated.
    I hope this is what you were looking for.

    Do you have the Application Designers Guide?
  • Mic28Mic28 Member Posts: 13
    Perfect, It works!!!, thanks for your help and time.
    Thanks again.
  • SavatageSavatage Member Posts: 7,142
    Where do I send my bill? :wink:
  • mabl4367mabl4367 Member Posts: 143
    You might want to put a call to an new function say "UpdateItemsFromVendor" in the vendor tables OnModify trigger. The new function should update field1 and filed2 on all items with the current Vendor No.

    It could look something like this:

    recItem.RESET();
    recItem.SETRANGE("Vendor No.",No.);
    IF xRec.Field1 <> Rec.Field1 THEN
    recItem.MODIFYALL(Filed1,Filed1);
    IF xRec.Field2 <> Rec.Field2 THEN
    recItem.MODIFYALL(Filed2,Filed2);
    recItem.SETRANGE("Vendor No.");

    This way the item table will be automatically uppdated when ever someone changes the values of field1 och 2 in the vendor table unless the vendortable is updated by code that doesn't call the OnModify trigger.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    You cannot create a tablerelation to a non-primairy key field.

    Actually you can do this. But if you do it will then be impossible to ever rename tables in Navision on that database, it will give an error that you need to include that field in a key in the table. And no hint at all where to find the problem.

    This was introduced in Navision ver. 1.1 to allow upgrades from 3.55, and to the best of my knowledge the bug has never been fixed. I reported it many times.
    David Singleton
  • BeliasBelias Member Posts: 2,998
    You cannot create a tablerelation to a non-primairy key field.

    Actually you can do this. But if you do it will then be impossible to ever rename tables in Navision on that database, it will give an error that you need to include that field in a key in the table. And no hint at all where to find the problem.

    This was introduced in Navision ver. 1.1 to allow upgrades from 3.55, and to the best of my knowledge the bug has never been fixed. I reported it many times.
    Can you please be more specific?I've just table related a non-primary key field to a non primary key field in another table...no problems in my RTC
    EDIT: sorry, it does not work...after clicking another field, the error line of RTC appeared in the header of the page...too bad... ](*,)
    well, it was not so important...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Belias wrote:
    You cannot create a tablerelation to a non-primairy key field.

    Actually you can do this. But if you do it will then be impossible to ever rename tables in Navision on that database, it will give an error that you need to include that field in a key in the table. And no hint at all where to find the problem.

    This was introduced in Navision ver. 1.1 to allow upgrades from 3.55, and to the best of my knowledge the bug has never been fixed. I reported it many times.
    Can you please be more specific?I've just table related a non-primary key field to a non primary key field in another table...no problems in my RTC
    EDIT: sorry, it does not work...after clicking another field, the error line of RTC appeared in the header of the page...too bad... ](*,)
    well, it was not so important...

    Just tried 2009SP1 Classic and the error is still there. Trying RTC now.
    David Singleton
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Tested in RTC, Same error.

    Can you let me know how you did it to make it work.
    David Singleton
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Import this object:
    OBJECT Table 50000 Test IPG
    {
      OBJECT-PROPERTIES
      {
        Date=02/03/10;
        Time=18:12:48;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
      }
      FIELDS
      {
        { 1   ;   ;Code                ;Code10         }
        { 10  ;   ;Inventory Posting Group;Code10     ;TableRelation=Item."Inventory Posting Group";
                                                       CaptionML=ENU=Inventory Posting Group }
      }
      KEYS
      {
        {    ;Code                                    ;Clustered=Yes }
      }
      FIELDGROUPS
      {
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    

    You just need to import it, nothing else.

    Then try to rename any item.
    David Singleton
  • BeliasBelias Member Posts: 2,998
    Tested in RTC, Same error.

    Can you let me know how you did it to make it work.
    you've probably not read the EDIT of my post ;)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Belias wrote:
    Tested in RTC, Same error.

    Can you let me know how you did it to make it work.
    you've probably not read the EDIT of my post ;)

    :x :x :x :x :x

    Edits should only be for mistakes in grammar etc. If the whole post changes add a new post so its clear.

    [-(
    David Singleton
  • BeliasBelias Member Posts: 2,998
    i edited it just 3-4 min. after...sorry to spare your time :|
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Belias wrote:
    i edited it just 3-4 min. after...sorry to spare your time :|

    No problem, I was very interested to find out if they had actually finally fixed this. :wink:

    Did you import my object to see that the bug is still there?
    David Singleton
  • BeliasBelias Member Posts: 2,998
    I just came back from holidays, sorry for the late answer...i didn't import your object, i tried it by myself, thanks a lot, anyway :thumbsup:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.