cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
azzamkaz
Level: Powered On

(important) using custom button to insert data to excel database

inn.PNGpicture 1exp.PNGpicture 2database.PNGpicture 3

hello guys, really need help ASAP . Smiley Sad

I'm making a rating apps. as shown in picture above.

The problem is when start to rate the user will rate base on choosing team, and select the creteria given by clicking the emoji button..... When the user click the emoji button the value goes in excel but not in a same row (refer picture 3) and the team name value still null.. The command that I use for emoji can refer(picture 1, picture 2)

 

Example... I want to make is 1 user goes in rate team(dropdown menu), click the emoji button innovation/experience/impact/collaboration/quality will goes in same ROW inside excel

 

thank you

azzamkaz

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: (important) using custom button to insert data to excel database

If you click any of the icons (you can do that while in preview mode, as it's easier to really click the icon without selecting it), then it will set the variable corresponding to the row that you click (innovation, experience, impact, ...). When the variable value is changed, then all formulas that reference that variable are recalculated.

 

So if you click on the "poor" icon for the innovation row, it will set the value of that variable to "poor", and you'll see the icon changing color.

32 REPLIES 32
Super User
Super User

Re: (important) using custom button to insert data to excel database

You're using Patch with the Default-function as second parameter, and then you create a new record, every time. So the formula works as you have written it.

 

To update a record, you have to have have the base record to change. Maybe you can get it from the selected item in the drop down; what's the Items property of it? Where do you get the team name from? In the excel file, no team name is set.

 

Read more about Patch here: https://docs.microsoft.com/en-us/powerapps/functions/function-patch

azzamkaz
Level: Powered On

Re: (important) using custom button to insert data to excel database

thank you @BitLord69 for the reply..

 

May I know which patch function should I used?

can you give 1 examples for one button(emoji)

 

Patch( Table1_1, Defaults( Table1_1 ), {NAME: User().FullName, INNOVATION: "Poor" } ) 

which part should I change in my code(code above)?

my data name : Table1_1

 

For the team name.., if user select in dropdown menu the value will go inside excel... I already put in Item list as shown below:-

["Team one","Team two","Team three","Team four","Team five"]

 

Super User
Super User

Re: (important) using custom button to insert data to excel database

Hi,

 

As I wrote in the first reply, you have to replace the Defaults-funciton and somehow get the currently edited record. When you use Defaults you create a new record. So, assuming there will be only one record per user you can do a Lookup to get the record to Patch:

 

Patch(Table1_1, Lookup(Table1_1, NAME=User().FullName), {...})

 

It seems this is the second screen in the app - how do you choose which user to rate and get to the second screen?

If the user doesn't have a record already, you have to create one using a call to Patch like you're already doing.

 

Tip - on app start, you might also want to set a global variable to the current user so you don't have to call the User-function all the time, i.e. Set(rCurrentUser, User()) and then you can use that variable in the formula above.

 

Another tip - if you're going to have lots of data you might want to look into saving in a proper database. Excel is good at many things, but it's not really a database. 

 

Good luck!

azzamkaz
Level: Powered On

Re: (important) using custom button to insert data to excel database

2.PNG 

I already using that code in picture above but no data go inside excel.

__________________________________________________________________________________

 

my first page only have one button to navigate to this rating page 

PowerApps Staff CarlosFigueira
PowerApps Staff

Re: (important) using custom button to insert data to excel database

You want the user to select all of the ratings before submitting, then you shouldn't use the Patch command in the images themselves. Instead, you can have some visual indication of what the user chose, and on the "check" icon on the top-right of your screen you can gather all the ratings for the different categories and create a new record (line) in your table.

 

An example is on the app shown below. Instead of having a single image for each rating, I have two versions: one with colors and one black-and-white (you may want to have different images instead of different colors as well, to account for users that need high-contrast displays)

 

ForumPost001.png

 

In each of the images, it sets the corresponding variable (innovation, experience, impact, collaboration, quality) to the rating value. The Image property of the image object uses the If function to decide which version of the image to use. For example, in the top-left image (poor, innovation), the Image property is set to

 

If(innovation = "poor", poor, 'poor-bw')

And the OnSelect is set to

 

UpdateContext({innovation:If(innovation = "poor", Blank(), "poor")})

 

When the user has selected all the ratings, he/she can then click the check box to submit the ratings, in which case the Patch command would use the value of all the variables to create the new row.

 

You can find one version of this app at https://1drv.ms/u/s!AonXZuy7S5iZiZ1Op9ZmbA8-6HuAbg. Notice that you'll need to update the connection to your own Excel table to make this work.

 

azzamkaz
Level: Powered On

Re: (important) using custom button to insert data to excel database

@CarlosFigueira

 when I change it become like this 

1.PNG

 

The emoji is image from outside not insert icon available in powerapps

 

PowerApps Staff CarlosFigueira
PowerApps Staff

Re: (important) using custom button to insert data to excel database

Yes, you'll need to have the different images. I searched for a website that could make B&W version of the images and converted them myself, and added them to the app. Feel free to save those (below) locally (naming them appropriately), and add them to your app.

average-bw.pngawesome-bw.pnggood-bw.pngpoor-bw.png

azzamkaz
Level: Powered On

Re: (important) using custom button to insert data to excel database

@CarlosFigueira

 

that mean I have to upload the B&W version on page and put at the color icon location overlap ? or only use the B&W emoji and use the code ?

 

 

then how about to insert the value like (poor,average,good,awesome) value inside excel row ?

PowerApps Staff CarlosFigueira
PowerApps Staff

Re: (important) using custom button to insert data to excel database

You'll need to upload the BW version of the files, but you don't need to use a different Image control - by setting the If expression that I mentioned above in the Image property of that control, you can choose between the two images depending on the value of the property.

 

And you'd insert the value in the "submit" button (in this case, the "check" icon on the top-right corner of the screen). The formula for it would be something along the lines of

Patch(
    Table1,
    Defaults(Table1),
    {
        NAME: TextInput1.Text,
        'TEAM_x0020_NAME': Dropdown1.Selected.Value,
        INNOVATION:innovation,
        EXPERIENCE:experience,
        IMPACT:impact,
        COLLABORATION:collab,
        QUALITY:quality
    }
)

Please download the app that I shared and look at it; you should see the formulas that are used to make this logic work.

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 528 members 5,168 guests
Please welcome our newest community members: