0

Automatic selection of record from linked table

I have a table called Sales invoices and this is linked to nominal ledger table. This allows me to select the relevant account for the sales transaction. However I'd like this to default to the sales account for every transaction as it will never change. Can anyone tell me if this is possible? I know I can use constraint so that the only acount visible is "sales" but I want to remove the step of actually selecting the account.

 

Thanks Noel

4 replies

null
    • Sean
    • 4 yrs ago
    • Reported - view

    Noel, If I understand correctly, you can use this...

     

    Sales := 1

     

    in "Trigger on create" in the nominal ledger table. This automatically selects the first and, I'm assuming, only record of the Sales table.

    • Mconneen
    • 4 yrs ago
    • Reported - view

    Noel, 

    Assuming your data model looks something like 

    dataModel

    And let us assume you have an Account Ledger that looks something like

    Accounts

    Then within your Sales Invoice Trigger On Create ... put something like the following:

    theCode

    Now when you create a Sales Inovice row.. it will default to the Sales account.. 

    SalesInvoices

    • info.16
    • 4 yrs ago
    • Reported - view

    Tanks guys - I'll give this a try

    • info.16
    • 4 yrs ago
    • Reported - view

    Thanks Mconneen - I tried this and it worked (after quite a lot of experimentation)

    Here's the syntax I arrived at that worked for me:

    let t := this;
    t.('Nominal Ledger' := first((select 'Nominal Ledger')[Name = "Sales"]))

    For some reason when it creates the new document it selects the date picker which isn't a show stopper

Content aside

  • 4 yrs agoLast active
  • 4Replies
  • 1681Views