0

Auto-populate one field based on another

How do I auto-calculate one field using the data in another?  e.g.  If 'Colour' field is "Blue", I need the 'Code' field to automatically poulate as '1'.  If I change the Colour to a different one, then the code shoudl correspondingly change automatically...

12 replies

null
    • Choices_Software_Dean
    • 5 yrs ago
    • Reported - view

    Use this code to get identifier for each color:

    let c := color(Colour);
    alert(text(c))

    Then use if then statement like this:

    let c := color(Colour);
    let t := text(c);
    if t = "#42A0FB" then
    1
    else
    if t = "#FC5A5A" then 2 end
    end

    • tonyt6
    • 5 yrs ago
    • Reported - view

    Thank you, Monk but I can't get this to work.  The colours are in a Field, 'Colour', which is a multiple choice field.  When I select the colour from the list, I need another field in the same table, 'Code', to auto-populate with the colour code ('1' for 'Blue'; '2' for 'Red'; '3' for White' etc. When I change the 'Colour' field, I need the 'Code' field to automatically update.

    • Choices_Software_Dean
    • 5 yrs ago
    • Reported - view

    Per docs, you can get value of a choice field like this:

    contains(text(Choice), "Blue")

    So set up your you if/then statements using that syntax to determin which color was chosen.

    • tonyt6
    • 5 yrs ago
    • Reported - view

    Thank you Monk.  That's got it!  Now I have two fields, each with auto-filled numeric values according to the solution you have provided. What I need to do is to create a third field that automatically calculates the product of the first two, but the expression ("Field 1" * "Field 2") just returns a 'invalid operator' error. I have spent hours trying to figure out different ways of doing this simple task, but getting nowhere.  Please will you advise.

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

    Try number(Field1)*number(Field2)

    maybe that will work

    Steven

    • tonyt6
    • 5 yrs ago
    • Reported - view

    Fantastic, Steven.  Thanks so much!  

    • tonyt6
    • 4 yrs ago
    • Reported - view

    Sorry.  Another query (I'm new to this!).  If I have two tables, one with all the details of all the Outlets, and the other one containing all the details of all the Products, and I link the tables, how do I ensure that when I open a single record - say, one Outlet - the linked Products table shows only the Products related to that Outlet, and not the details of all the Products.  I guess its to do with assigning an ID to the Outlets and assigning the same ID to the related Products, but I've no clue how to do it...

    • tonyt6
    • 4 yrs ago
    • Reported - view

    Sorry.  One more quick one - is there a mathematical facility to calculate the Median, as opposed to the Average (avg)?

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

    Oops , not compositions but 'Constraints' is the keyword.

    • jel888
    • 4 yrs ago
    • Reported - view

    Hello,

    I've spent the last hour trying to figure this out and can't? :(. I have a similar request of autopoulating a field based on the input in another field.  I need different things to populate depending on what the results are.  In three cases I want simple percentages to show "0%" and "100%" (with no user ability to change it), but in one case I want the field to populate with "10%" and allow the user to modify it. I'll also add field color changes for this one, but I think I'll be able to figure that out (maybe ;) ).  

    This is what I wrote, but nothing shows in the Taux... field (which I created as a formula field): 

    if 'Tâches'.Statut = 1 then
    'Taux de complétion' = 0
    else
    if 'Tâches'.Statut = 3 then
    'Taux de complétion' = 100
    else
    if 'Tâches'.Statut = 2 then
    'Taux de complétion' = 10

    if 'Tâches'.Statut = 4 then
    'Taux de complétion' = 0
    end
    end
    end
    end

    and then when it works, thought that a formula should go in the "Possiblity to write if" to have my second part work for the exception field (10% one); however it seems i can only do this in a number field (not the formula one, so I'm lost):

    if 'Tâches'.Statut = 2 then
    true
    else
    false
    end

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

    You should use := in stead of = in the code line.

    if 'Tâches'.Statut = 1 then
    'Taux de complétion' := 0
    else
    if 'Tâches'.Statut = 3 then
    'Taux de complétion' := 100
    else
    if 'Tâches'.Statut = 2 then
    'Taux de complétion' := 10

    if 'Tâches'.Statut = 4 then
    'Taux de complétion' := 0
    end
    end
    end
    end

    Steven

Content aside

  • 4 yrs agoLast active
  • 12Replies
  • 2921Views