cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JesusPrim
Regular Visitor

How to change local variable's value?

Hi, how to change the value of a variable ?

this code is executed by a button click so it creates a local variable.

 

 

UpdateContext({locDocument:{
    response:MyPowerAutomateFlow.Run(),
    extracontent:{extra1:1,extra2:"foo",extra3:false}}
    }
});

 

 

How can I toggle the value extra3 to true and false?

let's say locDocument.extracontent.extra3 = true or false  on another button click(I was thinking on a toggle control but button it's ok).

thanks.

3 ACCEPTED SOLUTIONS

Accepted Solutions
PG_WorXz10
Resident Rockstar
Resident Rockstar

Hi @JesusPrim 

 

Not sure if got the requirement correct but if you want to change only the value of extra3 on other button click you can try the below code. Let me know if it helps. 

UpdateContext({locDocument:{
    extracontent:{extra3:true}}
    }
);

 

View solution in original post

rahulswimmer
Helper II
Helper II

@JesusPrim On another button click, try this:

 

UpdateContext(
    {
        locDocument: {
            response: "",
            extracontent: {
                extra1: 1,
                extra2: "foo",
                extra3: !locDocument.extracontent.extra3
            }
        }
    }
);

View solution in original post

PG_WorXz10
Resident Rockstar
Resident Rockstar

Hi @JesusPrim ,

 

If there is no need of updating other variable context and you need to toggle the value of extra3 you can the below code. 

UpdateContext({locDocument:{
    extracontent:{extra3:!locDocument.extracontent.extra3}}
    }
);

View solution in original post

4 REPLIES 4
StalinPonnusamy
Community Champion
Community Champion

HI @JesusPrim

 

One other option is to split the string and concatenate it. Again PowerApps has fewer functions to extract specific strings like Left, Mid, Find..

 

Specific to JSON Power Automate is the easiest option.

 

PG_WorXz10
Resident Rockstar
Resident Rockstar

Hi @JesusPrim 

 

Not sure if got the requirement correct but if you want to change only the value of extra3 on other button click you can try the below code. Let me know if it helps. 

UpdateContext({locDocument:{
    extracontent:{extra3:true}}
    }
);

 

View solution in original post

rahulswimmer
Helper II
Helper II

@JesusPrim On another button click, try this:

 

UpdateContext(
    {
        locDocument: {
            response: "",
            extracontent: {
                extra1: 1,
                extra2: "foo",
                extra3: !locDocument.extracontent.extra3
            }
        }
    }
);

View solution in original post

PG_WorXz10
Resident Rockstar
Resident Rockstar

Hi @JesusPrim ,

 

If there is no need of updating other variable context and you need to toggle the value of extra3 you can the below code. 

UpdateContext({locDocument:{
    extracontent:{extra3:!locDocument.extracontent.extra3}}
    }
);

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,448)