cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
robertcaretta
Kudo Kingpin
Kudo Kingpin

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
v-micsh-msft
Community Support
Community Support

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
v-micsh-msft
Community Support
Community Support

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

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
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Users online (1,204)