cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Casting string to integer

Hi,

 

I'm trying to read a text field from a sharepoint list, cast it to an integer, do some math with it and cast it back to a string.

 

I have fetched the item from SharePoint and put the value of the string field in a Compose operation.

In the following compose operation I use the function in the Compose_9 action:

"@int('@{outputs(''Opstellen_8'')}')" where Opstellen_8 is the compose action that holds the string value. When the Flow has run, this string value is filled with 00001 which is correct. NB: Notice how I used double single quotes '' to escape the inner quotes around Opstellen_8 in order fo the function to validate successfully.

 

However, the cast to int action fails with the message: 'Cannot cast to targettype'.

Should this cast to int work for the value 00001? I would expect an Integer with value 1 from it.

 

What I'm trying to achieve is save a tracking number that is always 5 digits long with leading zero's, and increment it by one and save it back to SharePoint. I guess I could use a number field in the SP list but I would like to store the actual text presentation of the number including leading zero's). There are probably a ton of ways to do it, but I'd still like to know why the cast to integer fails. 

 

Kind Regards.

1 ACCEPTED SOLUTION

Accepted Solutions
Memorable Member
Memorable Member

Hi @Anonymous

 

Your compose function should contains this text: "@int('outputs('Opstellen_8')')" instead "@int('@{outputs(''Opstellen_8'')}')".

 

Best Regards,

 

Gustavo Moraes


Did I answer your question? Mark my post as a solution!

Gustavo Moraes, o astronauta brasileiro do Flow!


View solution in original post

2 REPLIES 2
Memorable Member
Memorable Member

Hi @Anonymous

 

Your compose function should contains this text: "@int('outputs('Opstellen_8')')" instead "@int('@{outputs(''Opstellen_8'')}')".

 

Best Regards,

 

Gustavo Moraes


Did I answer your question? Mark my post as a solution!

Gustavo Moraes, o astronauta brasileiro do Flow!


View solution in original post

Anonymous
Not applicable

Correct way is "@int(outputs('Opstellen_8'))" . Pretty simple really 🙂

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (52,214)