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

Calculation Field Converting String to Number

Jump to solution

Hi Community,

I have a form that is pulling user IDs, through user profile service. We are using a calculation field to do this but it is then automatically converting it to a number when its to be a string. So when we try to compare it in a rule to either show or not show a certain panel we are getting the wrong panel since its wanting to compare a numeric number to a string.  Why is it automatically converting the string of number to numeric and how can this be fixed?

Userprofilelookup("CurrentUser", "ID") is our formula in the calculation field box, to grab the users id which is a string of numbers.

Then we compare this to a string in a list to see if they are able to be involved in the poll.  Some users have a letter in there ID but most are all numbers.

Any insight or help on this is greatly appreciated.

Thanks,

Kevin

Reply
13 Replies
mapeacock
Nintex Newbie

Re: Calculation Field Converting String to Number

Jump to solution

Hi Kevin,

So I assume you are refering to a "Calculated Value" control on the form? If so, you do have the Save as data type set to string? I would think so. Sounds very strange.

Cheers,

Mark

0 Kudos
Reply
Automation Master
Automation Master

Re: Calculation Field Converting String to Number

Jump to solution

I came across this in the past too.

I reported it to support considering it's a bug but was moreless told it's a 'feature'...

basically, once a formula in calculated control value returns a value that is convertable to a numeric, it's treated as number regardless of what you set as datatype.

I was given workaround to encapsulate formula to a function that returns string, eg. tolower()

0 Kudos
Reply
kkittinger
Nintex Newbie

Re: Calculation Field Converting String to Number

Jump to solution

Mark,

That is how we set it up but that will only save the data you are doing to your column as a string which it does. But before it ever saves we have it doing a compare to another string but the calculation field is making the string of number into a Numeric value since its all numbers in the string.

0 Kudos
Reply
kkittinger
Nintex Newbie

Re: Calculation Field Converting String to Number

Jump to solution

Marian,

Did the tolower() work because I've done the toupper() and it didn't work it still calculated and read the string as a numeric value.

I've also found a couple other post and sounds like there was a fix to this back about a year ago but it messed up with a bunch of other thing so they took it out and where going to keep working on it. And last post i saw was there was to be a fix on it back in Jan. but haven't seen anything on it.

0 Kudos
Reply
Automation Master
Automation Master

Re: Calculation Field Converting String to Number

Jump to solution

for me it worked.

but till I got that workaround from support I find myself another one how to force it to return string, in your case it would be something like: Userprofilelookup("CurrentUser", "ID") +"x"

let's try it whether it will work for you.

I dealt with support reg. that 1 month ago and was told following when I asked if they plan to fix it.

The function that you have requested is still not part of our feature set

Reply
kkittinger
Nintex Newbie

Re: Calculation Field Converting String to Number

Jump to solution

Marian,

Thanks for your quick replies, ive tried both toLower() and toUpper() with no luck. Also tried the UserProfilelookup("currentuser", "id") + " ".

So we have a List Voters that will house IDs for the people that can vote on the poll, then the form checks if the user that is logged is in that list. So adding something to the end or front wont work to much.  Its just fun that its taking a string variable to start with then it just goes oh cause no letters in it, Im going to make it a numeric value.

Thank you again for the help and ideas you are given.

Reply
Automation Master
Automation Master

Re: Calculation Field Converting String to Number

Jump to solution

adding a space will not help, since it still doesn't prevent to convert it to numeric. just for the case try it with some non numeric character.

for me it as well caused lot of troubles since I had to strip that postfix off at every place I used the formula. but haven't found  anything better.

Reply
kkittinger
Nintex Newbie

Re: Calculation Field Converting String to Number

Jump to solution

Was looking behind the scenes in the code and Nintex has it built in that the if the calculation field recognizes a bunch of numbers to automatically change it to a numeric value.  Have read some post that at one time there was a fixes for that but that was un-patched and something was to be released in Jan. to fix this issue. Has there been any updates on that?

0 Kudos
Reply
kkittinger
Nintex Newbie

Re: Calculation Field Converting String to Number

Jump to solution

Have started to test this with other controls and even a form variable.  Even if I set Type to String, Nintex is automatically converting a string of numbers into a numeric value versus keeping it as a string.  Why is this and is there a fix for this? Is there a workaround to keep a string of numbers from becoming a numeric value?

0 Kudos
Reply