cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Oscar_Wan
Level: Powered On

String to Integer

Hi, could anyone advise how could I convert a string into an integer in a step down below a flow?

 

I composed using a formular, yet unsure why the output became a string and does not allow an update of an item. 

 

I got so frustrated a calulation formular with input of both integer when would end up a string output?! 

 

I have tried the expression Int(), but the error message still there. I have looked into the output, the calculation resulted in the correct output but the flow is yet successful. 

 

Much appreciate helps here. Thanks. 

 

Error.PNGstring to array.png

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: String to Integer

HI @Oscar_Wan 

 

Can you pelase share the reason you are using the '=' sign in the compose action? 

 

If there is no specific requirement for that, what you can do is, initialise a integre variable and set it to the value and use the expression 'int()' to convert the string type (provided the string is numbers). 

 

Also, you could directly use th int() function to wrap that that output formula of sub and put that in the update item action for the particular column using the expression editor. 

 

If you could share details on the compose actiona nd the formula, we might be able to assist you better. 

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

5 REPLIES 5
Dual Super User
Dual Super User

Re: String to Integer

HI @Oscar_Wan 

 

Can you pelase share the reason you are using the '=' sign in the compose action? 

 

If there is no specific requirement for that, what you can do is, initialise a integre variable and set it to the value and use the expression 'int()' to convert the string type (provided the string is numbers). 

 

Also, you could directly use th int() function to wrap that that output formula of sub and put that in the update item action for the particular column using the expression editor. 

 

If you could share details on the compose actiona nd the formula, we might be able to assist you better. 

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Oscar_Wan
Level: Powered On

Re: String to Integer

Thank you for your reply. 

 

I have tried to remove the "=" sign as there is no particular meaning. I have also tried to use the Int() expression to wrap the sub() formular, however, the same error message still there and the flow is unsuccessful. 

 

int(sub(items('Apply_to_each')?['EndingLeaveBalance'], triggerBody()?['Days_x0020_of_x0020_Leave']))

 

The initialize variable and set variable functions could only be established at the top and beginning of the flow. However, my flow requires this calculation only when a condition is satisfied and thus I was not able to initialize and set variable down my flow. 

 

Much appreciate your further advice. 

Dual Super User
Dual Super User

Re: String to Integer

@Oscar_Wan 

 

Looks like the issue is not with integer type for the value item to update. 

 

If you see the error closely, it says that the apply to each 2 has failed because the value it was expecting was an array and a string was provided. (the output of your compose action is a string and not an array and so you cannot use that as a value for the apply to each control) You need to delete the apply to each control and the compose action too. You just need the Update Item 4 action and in the column you can put the sub() formula. 

 

Can you please try this and check if you continue to face any issue?

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Oscar_Wan
Level: Powered On

Re: String to Integer

Thanks so much Yashag for your guidance.  You have always been very helpful.

 

It worked!! I have initialized the variable at the top and set the varible value as "0" and set variable output down below the flow. 

 

initialize variables.PNGworked.png

 

 

Dual Super User
Dual Super User

Re: String to Integer

Hey @Oscar_Wan 

 

Awesome! Glad I was of some help and you were able to resolve this!!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 349 members 7,049 guests
Please welcome our newest community members: