0

How to affect a value to a multiple choice field by script?

Hello,

I try to remove with an action button my initials of the multiple choice field 'ouvert par 2' of all record where my initials are in 'ouvert par 2', keeping the others initials inchanged...

 

thanks a lot,

Marc

4 replies

null
    • Nick_Massie
    • 4 yrs ago
    • Reported - view

    Remember sometimes you need to select by the number of the choice field.  Other times i have had to use "like" instead of = . 

    • Emanuel_Neubert
    • 4 yrs ago
    • Reported - view

    Hi Marc,

    what you can do is following. You need to get the selected values from your choice field with the numbers statement let x:= (numbers('Ouvert par 2')) and replace the ",PT" with "" (let y:= replace(text(x),",2","")). Afterwards you need to set the multiple choice field again ('Ouvert par 2' := y). Haven't tried it but it supposed to work.

    • Marc_Di_Francia
    • 4 yrs ago
    • Reported - view

    Hello Emanuel, two good tricks in two days !!!Thanks for indicating me to use the numbers() function in order to extract the array out of the multiple choice field. 
    However, the array to be reaffected into the field has to a numeric array. So after using the functions concat (), replace(), text(), the type of the array is not compatible anymore with the field.
    I found the way using a loop to remove a specified item from the array, keeping it numeric... and it works;

    let a1 := numbers('Ouvert par 2');
    let max := cnt(a1);
    let itemaretirer := 3;
    var newArray := for idx from 0 to max do
    if item(a1, idx) = itemaretirer then
    0
    else
    item(a1, idx)
    end
    end;
    'Ouvert par 2' := newArray

    Best regards
    Marc

    • yinapps.com
    • drew
    • 4 yrs ago
    • Reported - view

    Marc: i am new with Ninox so this standard logic may not apply, but if the array is 0-based, max should be (actual max) - 1 so that you don't refer beyond the bounds of the 0-based array.

Content aside

  • 4 yrs agoLast active
  • 4Replies
  • 1847Views