Default value for new field in a form

david.weeksdavid.weeks Member Posts: 96
edited 2004-05-16 in Navision Attain
Hello All

I have added a new field to the Sales Header Form (orders). This is ship-to territory. I want this to default to the value already selected in the territory field in the Customer card.

If required the user can then change this value by looking up the territory code (already done this).

What is the best approach for achieving this?

Thanks

Comments

  • sjansjan Member Posts: 16
    You can put piece of code in table Sales Order.OnInsert.
    Something like:
    Customer.RESET;
    Customer.SETFILTER("No.","Sales Order".CustomerNo);
    IF Customer.FIND('-') THEN
    NewField := Customer.TerritoryField;
  • Dean_AxonDean_Axon Member Posts: 193
    Customer.RESET;
    Customer.SETFILTER("No.","Sales Order".CustomerNo);
    IF Customer.FIND('-') THEN
    NewField := Customer.TerritoryField;

    That will work once the record has been inserted to the DB :)

    From a processing point of view I would recommend:

    On Validate trigger of the "Sell-to Customer No." field look for the following statement:

    GetCust("Sell-to Customer No.");

    There is a whole section of code that deals with getting information from the customer card. All you would need to do is add the following line:

    NewField := Customer.TerritoryField;

    Job Sorted :)

    The advantage to this is that yo are not repeating any GET functions AND if the customer is changed for whatever reason, then this would form part of the STANDARD replace customer routine .

    Dean
    Remember: Keep it simple
  • sjansjan Member Posts: 16
    Dean Axon wrote:
    Customer.RESET;
    Customer.SETFILTER("No.","Sales Order".CustomerNo);
    IF Customer.FIND('-') THEN
    NewField := Customer.TerritoryField;

    That will work once the record has been inserted to the DB :)

    From a processing point of view I would recommend:

    On Validate trigger of the "Sell-to Customer No." field look for the following statement:

    GetCust("Sell-to Customer No.");

    There is a whole section of code that deals with getting information from the customer card. All you would need to do is add the following line:

    NewField := Customer.TerritoryField;

    Job Sorted :)

    The advantage to this is that yo are not repeating any GET functions AND if the customer is changed for whatever reason, then this would form part of the STANDARD replace customer routine .

    Dean

    Or that. ;):)
  • david.weeksdavid.weeks Member Posts: 96
    Thanks guys, this was a great help!
  • RobertMoRobertMo Member Posts: 484
    If required the user can then change this value by looking up the territory code (already done this).
    And you probably havn't done this on form but just have added table relation to Territory table on your field in Sales Header...
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Sign In or Register to comment.