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}}
    }
);

 

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

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}}
    }
);

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

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}}
    }
);

 

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

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}}
    }
);

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Users online (1,416)