0

Select an element of choice dynamic in formula

In table TabA I have field 'Year' (field choice dynamic) which takes from table TabB the following data (field number):

2022
2023
2024
2025
2026
2027
2028
2029

In the taba table I have a button that creates a new record within the same table.

In the creation of the new record I would like to include a specific year, for example 2025.

I can’t do it!

I’ve tried them all

let a := 4
let new := create TabA
new.(Year := a)

let a := 2025
let new := create TabA
new.(Year := a)

let a := number(2025)
let new := create TabA
new.(Year := a)

let a :=record('TabB',4)
let new := create TabA
new.(Year := a)

ecc. 

What is the right code?

Thank you!

6 replies

null
    • Ninox partner
    • RoSoft_Steven.1
    • 2 yrs ago
    • Reported - view
    let y := number(Year);
    let c := (create TabA);
    c.(Year := y)
    
    • Fred
    • 2 yrs ago
    • Reported - view

    It is interesting that your last example didn’t work. What data was put in Year when you used it?

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

    Fred

    You're right, the last code does work , it takes always the same value from the TabB.(with ID 4)

    My code takes the value from the current record in TabA where the button is pressed.

    I must have read the question wrong.

    Up to Web Name  which code suites best for his case.

      • Fred
      • 2 yrs ago
      • Reported - view

      RoSoft_Steven I wasn’t trying to imply any issues with your code, as I depend on you to correct mine. In fact it is what I would use. I’m asking the question to troubleshoot.

      Looking at it again, the first code should give you a result as well. I am guessing that record 4 in TabB is 2025, but I don’t know that and that is why I’m asking for the result.

      Web Name , what data is put in for the first bit code? Does it match the data for the last bit?

      A bit of background, code samples 2 and 3 will not work in a dynamic choice field because you need a use a record Id to set it. That is why samples 1 and 4 should give you some result. If that result is what you want is another issue.

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

      I hadn't taken it that way anyway Fred because I hadn't even paid attention to the above codes. Until you pointed it out and then indeed I saw it, you were also right. Anyway,

      Should it interest you, this oneliner works as well:

      (create TabA).(Year := 4)

    • Web_Namer
    • 2 yrs ago
    • Reported - view

    Fred RoSoft_Steven

    Thank you for your interest!

    I would like to take the data from the TabB.
    And the record 4 corresponds to 2025.

    But the thing that leaves me puzzled is that the codes that I provided before, the first and the fourth, work perfectly.

    This isn’t the first time that codes don’t work for a while. After a while they work. I can’t explain this!

    Has that ever happened to you?

Content aside

  • Status Answered
  • 2 yrs agoLast active
  • 6Replies
  • 128Views
  • 3 Following