0

Replacing one value in a field with another value for records that match

I think I must be approaching this problem in the wrong way but ..

I have a table which contains a numeric value. I want to replace all occurences of the number 1 with the number 0 for all record where this field currently contains the number 1. I have, so far, found this impossible to do. Ninox wants to replace any record which has the number 1 anywhere within it. What am I doing wrong ?

7 replies

null
    • Sean
    • 4 yrs ago
    • Reported - view

    There are a couple of ways that I know of. You can use "Update Multiple Records", select "Assign calculated value" and use this formula...

     

    if NumberField = 1 then
    number(replace(text(NumberField), "1", "0"))
    else
    NumberField
    end

     

    You can attach this code to a Button or run it in the Console...

     

    for r in select YourTable do
    if r.NumberField = 1 then r.(NumberField := 0) end
    end

    • Dev_twentyZen
    • 2 yrs ago
    • Reported - view

    @sean I am trying to use replace('E-mail', "<", "") in Trigger after update but this replace function is not working in my case. I actually want to get string between these brackets <somestring>. Is there any solution for this? 

    • Sean
    • 2 yrs ago
    • Reported - view

    Dev twentyZen, you can do something like this…

    replace('E-mail, "<", "<" + somestring)

    • UweG
    • 2 yrs ago
    • Reported - view

    replace(extractx('E-mail', "(?=\<)(.*?)(?=\>)"), "<", "")

    • Sean
    • 2 yrs ago
    • Reported - view

    Hi Uwe,

    It looks like you just added pattern matching to Dev's misuse of the replace function. From the manual...

     

    Screen Shot 2022-01-05 at 8.21.13 PM

     

    Both of you are just replacing "<" with an empty string.

    • UweG
    • 2 yrs ago
    • Reported - view

    Hello Sean
    You are actually right about that.
    The correct regex would be:
    (?<=\<)(.*?)(?=\>).
    However, Ninox cannot do a 'positive lookbehind' in this case.
    Therefore: (?=\<)(.*?)(?=\>).
    The "" in replace(extractx(title, "(?=\<)(.*?)(?=\>)"), "<", "") does not create a space , but replaces the < character with 'nothing', so removes the < character.

    • Sean
    • 2 yrs ago
    • Reported - view

    Well, that's an interesting explanation, but it's irrelevant for the stated requirement.

Content aside

  • 2 yrs agoLast active
  • 7Replies
  • 1689Views