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

Change Form Color after successful Item patch

Hey,

 

I want to change the color of my edit form after successful patching in green, the item is patched with the following command.

 

 

 

UpdateContext({var_scan_result: TextInput2.Text}); Patch(InventoryList, LookUp(InventoryList, TAG_NUMBER = var_scan_result), {
        Status:
        {
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
            ID:1,
            Value:"Found"
        }
    }
)

 

 

 

If I look for a not exisiting "patch_number" the Background should change to red.

I have no idea how to realize this.

 

It would be great if anybody could help me.

 

Kind regard

 

Kai

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@KaiW76 

Just change the Fill color of the Form to the following:

If(LookUp(InventoryList, TAG_NUMBER = TextInput2.Text, true), Green, Red)

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

8 REPLIES 8
Spamrancher
Helper III
Helper III

Here's how I would do it:

UpdateContext({isFound: LookUp(InventoryList, TAG_NUMBER = TextInput2.Text)});
UpdateContext({theColor: Color.Green});
If(IsBlank(isFound), 
UpdateContext({theColor: Color.Red}),
Patch(InventoryList, isFound, {......what you already have})

Set the background to "theColor".

KaiW76
Frequent Visitor

Thanks for the quick response, but I have a Question:

 

What do you mean with "Set the background to "theColor"" ?

Should I insert Form1 or something like this?

You say "the background should change to red". The background of what control: the screen, the textbox, the button?

KaiW76
Frequent Visitor

Ok, than I understood you correct, I want to change the background of the form.

I will test it now

Spamrancher
Helper III
Helper III

Great. Then yes, change the Fill of the screen to "theColor". And you probably also want to add something to the screen's "OnVisible" property to set "theColor" to your base color (Color.White?). Otherwise it will stay red or green even if the user comes back with a new record.

 

Please mark this as solved if I helped you solve the problem.

KaiW76
Frequent Visitor

It does not work 😞
I will post the code and maybe you can see my fault::

 

UpdateContext({var_scan_result: TextInput2.Text}); 
UpdateContext({isFound: LookUp(InventoryList, TAG_NUMBER = TextInput2.Text)});
UpdateContext({ScanScreen: Color.Green});
If(IsBlank(isFound), 
UpdateContext({ScanScreen: Color.Red}),
Patch(InventoryList, LookUp(InventoryList, TAG_NUMBER = var_scan_result), {
        Status:
        {
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
            ID:1,
            Value:"Found"
        }
    }
)
)
RandyHayes
Super User III
Super User III

@KaiW76 

Just change the Fill color of the Form to the following:

If(LookUp(InventoryList, TAG_NUMBER = TextInput2.Text, true), Green, Red)

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

View solution in original post

KaiW76
Frequent Visitor

This works fine, thank you very much for your help.

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

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

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.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

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