IsNullOrEmpty not working in a calculated field


Badge +8

Greetings:

I am performing a database lookup into a drop down list when the form loads. Because nothing has been selected yet the value of that control is null or empty, which I have confirmed with a calculated field that has this formula (it shows 'Empty'): 

If(IsNullOrEmpty(manager),'Empty','Not Empty')

However, when I use the same IsNullOrEmpty fuction in another calculated control in which the following calculation is done on the FALSE condition:

If(isNullOrEmpty(manager),'Not Available',

toTitleCase(parseLookup(manager,false).split('.')[0])

+ ' ' +

toTitleCase(parseLookup(manager,false).split('.')[1])

)

I get this error:  "Unable to get property 'split' of undefined or null reference.  Am I doing something wrong in this formula? I know that manager is null or empty when the form loads, which means that the split function should not be called until I actually select something.  Yet is seems to be executing, or trying to, even though I'm stipulating that it not be run unless the manager control is neither null nor empty.

Thanks, in advance,

Bruce


13 replies

Userlevel 5
Badge +14

could you try following?

update your formula like this:

If(isNullOrEmpty(manager),'Not Available',

toTitleCase(parseLookup(writeConsole(manager,isNullOrEmpty(manager)),false).split('.')[0])

+ ' ' +

toTitleCase(parseLookup(manager,false).split('.')[1])

)

and add following fnc to form's javascript

function writeConsole(val,isnull){

  console.log('lookup val-<'+val + '>    len='+val.length+'      isnull='+isnull);

  return val;

}

I would be really interested in what will appear on console...

(unfortunately I do not have possibility to test it on my own)

Badge +8

Thanks for the reply but not much information there.  All I get is a bunch of permission denied errors:

SCRIPT70: Permission denied

File: NewForm.aspx, Line: 19, Column: 1

Userlevel 5
Badge +14

hm, I would say this is not related to the code I suggested to add.

what is line 19 about?

typically there are plenty of script includes at the beginning of NewForm.aspx, so it looks like you are trying to include a script/resource that you do not have permissions for.

Badge +8

No, I'm not adding anything besides the code you provided. At least not in the form's custom javascript section.  I will try to reproduce this in a completely new form, with nothing else besides the SQL control and the calculated field that references it.

Badge +8

I have created a brand new list and get exactly the same error message.  It doesn't seem to matter whether I put that formula in a calculated control or a form variable.

Adding the code you suggested also gives me the same error I reported above. Here is a screen shot.

Capture2.PNG

Userlevel 5
Badge +14

so as I suspected, you do not have permissions to load (or a file doesn't exists) init.js script.

but maybe later on another init.js script with another locale might be loaded, so it need not be an error to care about.

I would still check console window (not script itself) whether it gives some output

Badge +8

After further study it appears that the problem I'm experiencing is NOT with the IsNullOrEmpty() runtime function, which works just fine,  and not with the If() function, which also works.  I suspect that the parseLookup function must always run no matter what, ignoring the surrounding logic that would tell it not execute.

Userlevel 5
Badge +14

hm, that's really interesting finding....

I've setup small testcase and can confirm the behavior as well.

ie., whichever out of three 'slt1' text field,' lkp1' or 'lkp2' lookups I have changed, parseLookup() from both branches were invoked

Userlevel 4
Badge +11

Hi,

which version of Nintex Forms are you using? I've got a similar issue with calculated fields and if condition, where both the branches were invoked.

I've opened a ticket and the issue has been solved with the last version of Nintex Forms 2.9 that has come out lastJune 20th, so if you're not on the last version I suggest you to try to update (have a look also on the other posts here on the forum about the changes in the lookup controls)

Giacomo

Badge +8

Yes, I was just thinking about doing that.  I'm still on  version 1.11.0.0 and was planning to upgrade today.  WIll let you all know if this solves the issue!

Badge +8

I have completed the upgrade to 1.11.2.10.  Alas, this has not fixed the problem.

Userlevel 4
Badge +11

Sorry to hear that, in that case I think you should try to open a ticket to support..

Badge +8

I finally did get this to work.  The final version of the calculation is

     If(isNullOrEmpty(manager),'Not Available',toTitleCase(manager_uid.split('.')[0] + ' ' + manager_uid.split('.')[1]))

where manager_uid is a variable = parseLookup(manager, false).

So it appears that the upgrade did fix the If() problem after all.

Thanks to all who helped me solve this problem!

Reply