cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Kudo Commander
Kudo Commander

Initializing Integer Variable

Has anyone tried to initialize an integer variable from dynamic content? No matter what I do everything comes across as a string, even when using the int() function.  I'm trying to either convert an exisiting string variable OR set an integer variable from a microsoft form field.  Ideally I could convert this into an integer and leave it that way. 
@{int(substring(triggerBody()['raa1dad7fbf5d4bea93ffc74a658f7bd8'],0,3))}

 

When I try to initialize a int variable I get an error like this, even when using the int() function...
BadRequest. The variable 'vSchoolID' of type 'Integer' cannot be initialized or updated with value '26' of type 'String'. The variable 'vSchoolID' only supports values of types 'Integer'.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Initializing Integer Variable

Hi @robertcaretta,

 

The issue here should not be the Variable, but the value you configured with this variable.

"The variable 'vSchoolID' of type 'Integer' cannot be initialized or updated with value '26' of type 'String'."

If you leave the following code into the value input, it will add double quotes automatically, which will then convert any value into a string.

@{int(substring(triggerBody()['raa1dad7fbf5d4bea93ffc74a658f7bd8'],0,3))}

To make it work, take a try to add a Compose Action, then under the Compose Input, copy and paste the following:

"@int(substring(triggerBody()['raa1dad7fbf5d4bea93ffc74a658f7bd8'],0,3))"

After that, use the Compose output as the Variable value.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: Initializing Integer Variable

Hi @robertcaretta,

 

The issue here should not be the Variable, but the value you configured with this variable.

"The variable 'vSchoolID' of type 'Integer' cannot be initialized or updated with value '26' of type 'String'."

If you leave the following code into the value input, it will add double quotes automatically, which will then convert any value into a string.

@{int(substring(triggerBody()['raa1dad7fbf5d4bea93ffc74a658f7bd8'],0,3))}

To make it work, take a try to add a Compose Action, then under the Compose Input, copy and paste the following:

"@int(substring(triggerBody()['raa1dad7fbf5d4bea93ffc74a658f7bd8'],0,3))"

After that, use the Compose output as the Variable value.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Kudo Commander
Kudo Commander

Re: Initializing Integer Variable

That works, thanks. At least my JSON is properly formatted now.

Is there a reason why we can not initialize an integer variable with dynamic content?

Helpful resources

Announcements
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

Top Solution Authors
Users online (8,464)