내 커뮤니티 업적 표시줄을 확대합니다.

Don’t miss the Workfront AMA: System Smarts & Strategic Starts! Ask your questions about keeping Workfront running smoothly, planning enhancements, reporting, or adoption, and get practical insights from Adobe experts.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Converting String to Number in Fusion

Avatar

Level 7

This is a repeat question I'd asked - unanswered - in a subgroup on this site, so apologies if I'm over-posting... (edited to add PDF to illustrate the current observed behavior).

Is there a way to convert/coerce a variable data type to be a number instead of a string - particularly in the Set Variable module? I'm using the Set Variable module to initially set a var to zero; it treats it like a string. So after I set it, under certain conditions, I take the current variable value and have it add +1 to itself in a subsequent module. And I'm noticing that the subsequent module that adds 1 to the variable looks at the 0 as a string and sets the new value to "01". If I test-feed it a 3, it sets the value to "31".

If I feed it a 3, I would instead want it to compute and set the variable to 4. I'm not picky about whether it's an integer or float as long as I can do math with it.

How do I let Fusion know I want this to be a number and not a string? I am using the "+" operator from the math functions, and yet it's still treating the two values as strings.

Thanks!

주제

토픽은 커뮤니티 콘텐츠를 분류하여 관련성 있는 콘텐츠를 찾는 데 도움이 됩니다.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Level 4

Hi Mylah,

Thanks for all the details and screenshots. To accomplish this, simply use the parseNumber() function on the first module when you set the value to zero (e.g. parseNumber(0)) will, in fact, result in a number rather than a text string.

The default of the "Set Variable" module is string...so when setting a number like this...this parseNumber function will do the trick (you wouldn't need to do this if the number was an output from an API or something else).

원본 게시물의 솔루션 보기

2 답변 개

Avatar

정확한 답변 작성자:
Level 4

Hi Mylah,

Thanks for all the details and screenshots. To accomplish this, simply use the parseNumber() function on the first module when you set the value to zero (e.g. parseNumber(0)) will, in fact, result in a number rather than a text string.

The default of the "Set Variable" module is string...so when setting a number like this...this parseNumber function will do the trick (you wouldn't need to do this if the number was an output from an API or something else).

Avatar

Level 7

@Darin Patterson - inactive‚ Excellent! Thank you;

"parseNumber(0;,)" is what worked. 🙂

I'd considered using parseNumber or formatNumber, then promptly forgot to try those functions.