0

Auto filling in of address fields

Hi all

As new user i am just getting to grips with Ninox and getting on fine as already have found much vauable information from this forum. Hwoever i am a little lost regarding lookup information.

example. I have set up 2 tables

Company table - (fields include - CompanyID, Company, Address, Address2 etc)

Jobbag table (Fields include - JobBagID, CompanyID, DelCompany,Deladdress,deladdress1 etc

I have set up the relationship and link to etc.

but what i want to do is when filling in the job bag have the cdelivery to company and address fields auto fill in (bust still allow manual overtype if required (then i can produce a delivery note from this to printer)

My previous database (dataese) allowed this by setting up the relationship match between Company and JobBag with a field match on the CompanyID (and set as one to many) then embedding a lookup reference in each relevant field on the jobbag form (lookup company Address1)

So i am guessing i can use a trigger in some way (at field or form level to do this but am struggling with the syntax to use)

I would be most grateful if anyone can anyone kindly point me in the right direction

Kind regards and happy new year to you all.

9 replies

null
    • Choices_Software_Dean
    • 4 yrs ago
    • Reported - view

    Create "Company" relation from "Jobs" table and then enter script under that relation's "Trigger after update", like:

     

    let c := Company.Company;
    DelCompany := c;

    let a := Company.Address;
    Deladdress := a

    • Choices_Software_Dean
    • 4 yrs ago
    • Reported - view

    Then when you create a new Jobbag table record from the Company table, the Jobbag table's DelCompany and Deladdress fields will automatically fill from the Company relation. You will be able to edit the DelCompany and DelAddress fields without changing the related records. It that what you want?

    • Choices_Software_Dean
    • 4 yrs ago
    • Reported - view

    No need for the variables, just:

     

    DelCompany := Company.Company;

    Deladdress := Company.Address;

    • Mel_Charles
    • 4 yrs ago
    • Reported - view

    Hi Dean

    Brilliant. Will give it a try and let you know how i get on.

    Thank you in advance :-)

    • Mel_Charles
    • 4 yrs ago
    • Reported - view

    Hi Dean

    Works perfectly - You are a star !!

    Thank you :-)

    • Mel_Charles
    • 4 yrs ago
    • Reported - view

    Hi Dean

    On further testing. It appears that the above suggestion does indeed copy the company/address fields etc into both order from fields and deliverto fields. However I note that when i edit any one of the deliveryto fields to overtype an alternative delivery address. when I exit the field the lookup/relation re triggers the script refires the original request to copy the customer info into the same field.

    I guessing that it is because the trigger thinks it needs to pull the info down again on exit of the edited field.

    So is there any way to turn off the trigger after it has fires once?

    or could leave the delivery to filed blank initially and get a script onto a button to copy said info once. (or delere the fileds so i can manually type a new delivery address.

    Struggling to find any help on this in the user guide. 

    I suppose an Ideal senario would have the inital trigger copy the info into the order from fields. then have a button to copy order from fields into deliver to fields.

    Oh and i have replaced all sprate address1, address2 fields with one text memo filed as it seems more elegant.

    so jobs table (customer relation trigger on update) is

    let myD1 := Customers.MainAddress;
    DelAddress := myD1

    Jobs table mainaddres field (trigger on update)

    DelAddress := Customers.MainAddress

    any thoughts ?

    • Choices_Software_Dean
    • 4 yrs ago
    • Reported - view

    At the moment I am buried in a project. Maybe someone else can help.

    • Ninox partner
    • RoSoft_Steven.1
    • 4 yrs ago
    • Reported - view

    Something like this:

    if field = null then 'your formula' end

    then it will only update if the field is emty.

    Steven

    • Mel_Charles
    • 4 yrs ago
    • Reported - view

    Brill - Works :-)

    Thank you!

Content aside

  • 4 yrs agoLast active
  • 9Replies
  • 2023Views