Apply Vendor Template in CSIDE

jimmyfjimmyf Member Posts: 104
Hi I am trying to apply a Vendor Template to a new Vendor record programmatically in Nav 2013.

If I debug the code the values in the fields configured in the Configuration template lines table seem to be applied however when I run the vendor card the fields are blank!

I have a vendor record variable called recVend and I am using the standard codeunit, Config. Template Management in variable ConfigTemplateMgt
I have attached a screenshot of the template
Here is the code I am using

IF ConfigTemplateHeader.GET(recWTsetup."Employee Vendor Template") THEN BEGIN
RecRef.GETTABLE(recVend);
ConfigTemplateMgt.UpdateRecord(ConfigTemplateHeader,RecRef);
END;
recVend.MODIFY;

Comments

  • pvrbpvrb Member Posts: 17
    Good morning,

    I trust the UpdateRecord procedure modifies the Vendor record but keeps original values in your recVend.
    So the " recVend.MODIFY; " seems to return all values of the vendor record to the pre-template state.

    If you need to "update" recVend in your Nav code, you might like to try this:
    IF ConfigTemplateHeader.GET(recWTsetup."Employee Vendor Template") THEN BEGIN
      RecRef.GETTABLE(recVend);
      ConfigTemplateMgt.UpdateRecord(ConfigTemplateHeader,RecRef);
    END;
     
    //2014-08-28->
    //recVend.MODIFY;
    recVend.GET(recVend."No.");
    //<-
    

    Might work. If not, well, I'm just a former consultant...

    Kind regards,
    Pavel.
  • jimmyfjimmyf Member Posts: 104
    I eventually worked it out.

    RecRef.SETTABLE(recVend); //Apply RecRef to recVend
    recVend.MODIFY;


    By doing a SETTABLE on the Record Ref variable updated the vendor record with the values assigned o the RecRef.

    Thanks anyway
Sign In or Register to comment.