0

Set another field's value from calculation?

Is it possible to set another field's value (in the same table) from a calculation? I haven't been able to do it. The calculation would also set its own field's value.

If I have calculated field and I try to set another field with the calculation's result, nothing happens.

Can't find anything documented or examples.

Possible?

Thx,

8 replies

null
    • Fred
    • 2 yrs ago
    • Reported - view

    What is your code?

      • ninox.1
      • 2 yrs ago
      • Reported - view

      Fred I have a calculation field called 'calcwt' and another regular text field called weight.

      Inside the calcwt field, I calculate the decimal pounds + ounces entered like this:

      let i := wt_pounds + wt_ounces/16

      I'd then like to take that value and populate the regular 'weight' text field with it.

      That is, assign the calculated value, i, both to the calculated field itself, but also to the other text field.

      My issue is trying to convert a small application to Ninox. Some of the conversions from pounds and ounces were done in a completely different way in the other DB.

      Does that help?

      P.S. Does Ninox have a comment symbol for scripts?

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

    Textfield := text(Formulafield)

    Or

    Numberfield := number(Formulafield)

    A trigger with a button is needed.

      • ninox.1
      • 2 yrs ago
      • Reported - view

      RoSoft_Steven Rooryck If I go into the formula field and type:

      weight := text(this)

      I get the message that "This formula may not modify data."

      That's the error I got before.

      I may have the context for my code incorrect?

      Thanks

    • Fred
    • 2 yrs ago
    • Reported - view

    Yeah, formula fields can't modify other fields. They can only do functions to get data.

    As Steven says, you either have to

    1. use a button
    2. put it in On Click for the formula field
    3. put it in Trigger after update at the Table level

    All you need at this level is:

    weight := calcwt
    
      • ninox.1
      • 2 yrs ago
      • Reported - view

      Fred You guys are great. Thanks!!! :)

      • Alan_Cooke.1
      • 2 yrs ago
      • Reported - view

      Mike To comment simply surround the line with:

      "this is  a comment";

      next line

      • ninox.1
      • 2 yrs ago
      • Reported - view

      Alan Cooke Thanks Alan. I was searching all over for the "//" or the "#" or other preceding comment symbol like in programming languages. I couldn't find anything in the manual. A simple quote never occurred to me. :)

Content aside

  • 2 yrs agoLast active
  • 8Replies
  • 570Views
  • 4 Following