0

This is driving me crazy

Will someone please test this code in a new database and in the "Global script definitions". I want to know if it works correctly for someone else who hasn't done what I did. I was testing to see if it worked in both the "Global script definitions" and locally in a formula. It worked once, but then quit working when called from "Global script definitions". I finally figured out that if I put a useless function in as the first function all of my other functions would work. Here is the function...

 

function aAppend(ary : text,newItem : text) do
if count(ary) > 0 then
split(replace(ary, ", ", ",") + "," + newItem, ",")
else
split(newItem, ",")
end
end;

 

Call it like this in a formula field...

 

let a1 := [""];
a1 := aAppend(concat(a1), "Test 1");
a1 := aAppend(concat(a1), "Test 2");
concat(a1) 

 

It should produce this output... Test 1, Test 2. I've tried deleting the original database and creating new ones and power cycling my computer. The only thing I haven't done is delete the app and reinstalled it. Thanks in advance.

13 replies

null
    • Sean
    • 5 yrs ago
    • Reported - view

    Ninox Team? Commenting before the function in "Global script definitions" does not work either. Also, maybe I didn't explain what I did clearly... I created the function above in the "Global script definitions" and it worked fine when I called it. I also defined it in a formula with the same code and name.

    • Sean
    • 5 yrs ago
    • Reported - view

    When I defined it in a formula field also, it was not in the same formula field that I made the function call to the global function.

    • Sean
    • 5 yrs ago
    • Reported - view

    December 1?

    • Sean
    • 5 yrs ago
    • Reported - view

    Another observation, if I define the function locally in a formula field it works. It also works in the console. Renaming it from aAppend() to testFunction() doesn't solve the issue. The only way I have been able to call it from "Global script definitions" is to have a junk UDF declared above it. This is what I use...

     

    function textLength(myString : text) do
    length(myString)
    end; 

     

    I don't have to call it, but it's still annoying. Finally, for now, it's only the first function that doesn't work correctly; all the functions defined after it work just fine.

    • K_Gamble
    • 5 yrs ago
    • Reported - view

    I also noticed whatever the first function is in the Global functions will not work - so just put in a dummy one as the first function and the rest seem to work fine.

    • Sean
    • 5 yrs ago
    • Reported - view

    Thank you!!! I honestly had not noticed that. I thought it was because I had defined the same function globally and locally 

    • Sean
    • 5 yrs ago
    • Reported - view

    I won’t put money on it, but I’m pretty confident it worked in the beginning and before I defined the same function locally. I was going to delete the app and reinstall it, but I might wait now.

    • Sean
    • 5 yrs ago
    • Reported - view

    Ok, now that the rest of your post sank in it could have been after I started adding more functions. It’s been a long day 

    • blackie
    • 5 yrs ago
    • Reported - view

    If I don't have the dummy global function, the else statement is always run, so I end up with just "Test 2" at the end in the formula.

     

    If I add the dummy global function, it works and I get "Test 1, Test 2"

    • Sean
    • 5 yrs ago
    • Reported - view

    Exactly!!! And one of the things that kept me going in circles is my dummy function works like it's supposed to.

    • Mconneen
    • 5 yrs ago
    • Reported - view

    You guys are awesome testers.. :) 

    • Sean
    • 5 yrs ago
    • Reported - view

    That gave me a good chuckle... the beer helps too. :)

    • Frank_Bohmer
    • 5 yrs ago
    • Reported - view

    That's clearly a bug. We'll analyze this and fix it with the next release.

Content aside

  • 5 yrs agoLast active
  • 13Replies
  • 4102Views
  • 1 Following