0

Copy contents of reference link to another field.

Hello.

The "Select" field you see in the screenshot is a "Link to" reference.
My intention is that whatever is selected, should be copied over to the "Description" field (text field).

I added a code to the "Trigger after update" section of the "Select" reference field.

let x := Select;
Description := x.Description1

But of course this doesn't copy the selection over and every time I change the selection field, it changes the "Description" field. So basically that "trigger after update" doesn't serve my purpose. How else could I accomplish this?

In FileMaker we used an editable selection field. We could select an item and then add some comment. In Ninox this seems not to be possible. Using choice fields, we can't amend the selection.

Any help or suggestion is much appreciated :)
 

7 replies

null
    • mpm
    • 2 yrs ago
    • Reported - view

    If the Description field always has to show the text of the selected item, you could make the Description field a formula field (instead of a text field) with in the formula the Select field. The Description field then always shows the Select field

      • NetSol Co., Ltd.
      • Bernd_Krell
      • 2 yrs ago
      • Reported - view

      Marjolijn Thank you. But then I assume we can't amend it, can we?
      I would still prefer to have the selection copied over to the description field. And if the description field also has contents, then just append it.

      • mpm
      • 2 yrs ago
      • Reported - view

      Bernd Krell That is correct. An other possibility is to add a second Description2 field as a formula: text(Select + " " + Description1). This field will combine the Select field with the text from field Description1 with a space inbetween. The Description2 field then is a formula so it cannot be directly amended but the Description1 field can.

      If necessary you can hide one or the other description fields. I have a similar thing and added a choice box ("change text field"). After putting it on "Yes" the Description2 is hidden and I can amend the Description1. Putting it back to "no" hides the Description1 and the Description2 field is visible with the new text.

    • Producer, Manager
    • Jan_Inge_Iversen
    • 2 yrs ago
    • Reported - view

    What about this?
    Description := text(Select) *on the trigger After Update*

      • NetSol Co., Ltd.
      • Bernd_Krell
      • 2 yrs ago
      • Reported - view

      Jan Inge Iversen This is a shorter version of my script. Good to learn how to make it short but it doesn't copy the selection in the Description field. It shows it but not copy. That's probably due to the "trigger after update".
      Is it possible to add a command to append the selection in the Description field?
      Means I use the drop down and select something, it adds it to the Description field.
      Then I select something else and it appends it. Possible?

    • Fred
    • 2 yrs ago
    • Reported - view
    Bernd Krell said:
    Then I select something else and it appends it. Possible?

     Most things are possible. You can try this in your trigger:

    let t := this;
    if Description = null then
    Description := Select.Description1
    else
    Description := t.Description + "
    " + Select.Description1
    end
    

    Line 1 creates a reference to the current record.

    Line 2 - 7 is an if statement that checks if the Description field is empty or not. If it is then it copies the data from the Description1 field from the Select link.

    If the Description field is NOT empty, then it takes the content of the current Description field then adds a paragraph mark then adds the content of the Description1 field from the Select link.

    • NetSol Co., Ltd.
    • Bernd_Krell
    • 2 yrs ago
    • Reported - view

    Fred Sorry for the delay and replying. I was away.
    Tried your code and it works perfectly, doing exactly what I needed :)

    Thanks a lot, great help. 👍

Content aside

  • Status Answered
  • 2 yrs agoLast active
  • 7Replies
  • 125Views
  • 4 Following