cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
manvinder277
Frequent Visitor

Error while using Set

Error while using Button - OnSelect
 
error.png
The code does not work, it throws error-message at last line
 
Can someone please help me?
1 ACCEPTED SOLUTION

Accepted Solutions

Hi @manvinder277 

I understand why you want to do this, and how it is standard practice in VB, C etc.

Rather than call the set function to assign a variable to a variable, I would call the value function to return the numeric value. The formula would look like this:

Set(val1,10);
Set(val2,Value(val1));
Set(val1,20);
Set(val1,Value(val2))

 

View solution in original post

6 REPLIES 6
eka24
Super User III
Super User III

The variables with text should be in quotes.

Set(var1,10);Set(var2,"fgg");Set(var3,50)

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

I do not think the quotes are a problem, 

 

This works

Set(va1,10);Set(va2,va1);Set(va1,20)

 

but when I add one more statement Set(va1,va2), it does not work

Set(va1,10);Set(va2,va1);Set(va1,20);Set(va1,va2)  it shows error.

 

 

 

 

 

 

 

Becasue you are reusing the name of the variable which already exist
Set(va1,10);Set(va2,va1);Set(va1,20);Set(va1,va2) it shows error.

Set(va2,va1);Set(va1,va2)

correct va2

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

What I am trying to do is following and it works in ALL the other codes (C, VB....) but not here

va1=10     I set va1 to a value

va2=va1   keep the value of va1 in va2 

va1=20    do something with va1.... 

va1=va2   now I want the original value of va1 back...... Here powerapps throws error!

 

 

This one works. The issue is the uniqueness of the Variable name:

Set(var1,10);Set(var2,"LLL");Set(var3,var1)
------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Hi @manvinder277 

I understand why you want to do this, and how it is standard practice in VB, C etc.

Rather than call the set function to assign a variable to a variable, I would call the value function to return the numeric value. The formula would look like this:

Set(val1,10);
Set(val2,Value(val1));
Set(val1,20);
Set(val1,Value(val2))

 

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

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.

Top Solution Authors
Top Kudoed Authors
Users online (2,246)