cancel
Showing results for 
Search instead for 
Did you mean: 
baltner
Nintex Newbie

IsNullOrEmpty not working in a calculated field

Jump to solution

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

Labels: (2)
Tags (1)
Reply
13 Replies
Automation Master
Automation Master

Re: IsNullOrEmpty not working in a calculated field

Jump to solution

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)

0 Kudos
Reply
baltner
Nintex Newbie

Re: IsNullOrEmpty not working in a calculated field

Jump to solution

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

0 Kudos
Reply
Automation Master
Automation Master

Re: IsNullOrEmpty not working in a calculated field

Jump to solution

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.

0 Kudos
Reply
baltner
Nintex Newbie

Re: IsNullOrEmpty not working in a calculated field

Jump to solution

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.

0 Kudos
Reply
baltner
Nintex Newbie

Re: IsNullOrEmpty not working in a calculated field

Jump to solution

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

0 Kudos
Reply
Automation Master
Automation Master

Re: IsNullOrEmpty not working in a calculated field

Jump to solution

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

0 Kudos
Reply
baltner
Nintex Newbie

Re: IsNullOrEmpty not working in a calculated field

Jump to solution

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.

0 Kudos
Reply
Automation Master
Automation Master

Re: IsNullOrEmpty not working in a calculated field

Jump to solution

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

0 Kudos
Reply
Automation Master
Automation Master

Re: IsNullOrEmpty not working in a calculated field

Jump to solution

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

0 Kudos
Reply