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

Employee Engagement Survey Mod

I am not a programmer, so bare with me...

 

I have an app based on the Employee Engagement Survey that I have modified to fit my needs except for one step.

 

For each new 'survey' that is completed and posted to the data file, it is not appended, but over-writes the existing data. How do i modify the program to append to the next available row in exel to keep a running log?

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

Hi @iPhoneBeta,

 

This Survery won't create a new record for the same user in the Excel file.

Actually, it will first check to see if there is a record for the user logged in, if yes, this App will update the existing record.

The structure of the Next button under the Question 5 screen is as below:

If(!IsBlank(LookUp(Responses,Username=User().FullName,Responses)),
UpdateIf(Responses,Username=User().FullName,{Record}), UpdateContext({NewSurvey: Patch(Responses,Defaults(Responses), {Record})}))

So if here you would like to just creating new record for the same user, then you can remove the If condition check and only leave the UpdateContext() part.

For example:

UpdateContext({NewSurvey:
Patch(Responses,
Defaults(Responses),
{ResponseId:Text(CountRows(Responses)+1),
Answer1:Radio1.Selected.OptionText,
Answer2:Replace(Concat(Listcollect,OptionText & ", "),Len(Concat(Listcollect,OptionText & ", "))-1,1," "),
Answer3:Text(Slider1.Value),
Answer4:If(Radio1_1.Selected.OptionText="No","No," & TextInput1.Text,Radio1_1.Selected.OptionText),
Answer5:TextInput1_1.Text,Username:User().FullName})});
Navigate(Finish_Screen,ScreenTransition.Fade)

Copy and paste the code above should be OK to have the App only creating new records, instead of Updating the existing record.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

V-Misch- 

          Thank you for breaking out the solution. I had to remove one extra close parenthesis, but all else worked great.

 

Final code:

 

UpdateContext({NewSurvey:Patch(Responses,Defaults(Responses), {ResponseId:Text(CountRows(Responses)+1), Answer1:Radio1.Selected.OptionText,Answer2:Replace(Concat(Listcollect,OptionText & ", "),Len(Concat(Listcollect,OptionText & ", "))-1,1," "),Answer3:Text(Slider1.Value), Answer4:If(Radio1_1.Selected.OptionText="No","No," & TextInput1.Text,Radio1_1.Selected.OptionText),Answer5:TextInput1_1.Text,Username:User().FullName})});Navigate(Finish_Screen,ScreenTransition.Fade)

View solution in original post

4 REPLIES 4
Rebetcha
MVP

I looked in on that template. At first glance it looks like all the answers are stored as a variable until the NEXT button on the screen with the last question. You should have a good look at the formula on that button. Did you change anything in that formula? The formula uses the patch function that can both create and update a record. The problem you are facing most likely is solved in this formula. More on the patch-function in this article: https://docs.microsoft.com/en-us/powerapps/functions/function-patch.

Thanks Rebetcha for the link. To answer you question- No, I didn't modify that formula. Just to be sure, I tested the original unaldulatered Engagement Survey, and it also does not append the new data. 

Hi @iPhoneBeta,

 

This Survery won't create a new record for the same user in the Excel file.

Actually, it will first check to see if there is a record for the user logged in, if yes, this App will update the existing record.

The structure of the Next button under the Question 5 screen is as below:

If(!IsBlank(LookUp(Responses,Username=User().FullName,Responses)),
UpdateIf(Responses,Username=User().FullName,{Record}), UpdateContext({NewSurvey: Patch(Responses,Defaults(Responses), {Record})}))

So if here you would like to just creating new record for the same user, then you can remove the If condition check and only leave the UpdateContext() part.

For example:

UpdateContext({NewSurvey:
Patch(Responses,
Defaults(Responses),
{ResponseId:Text(CountRows(Responses)+1),
Answer1:Radio1.Selected.OptionText,
Answer2:Replace(Concat(Listcollect,OptionText & ", "),Len(Concat(Listcollect,OptionText & ", "))-1,1," "),
Answer3:Text(Slider1.Value),
Answer4:If(Radio1_1.Selected.OptionText="No","No," & TextInput1.Text,Radio1_1.Selected.OptionText),
Answer5:TextInput1_1.Text,Username:User().FullName})});
Navigate(Finish_Screen,ScreenTransition.Fade)

Copy and paste the code above should be OK to have the App only creating new records, instead of Updating the existing record.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

V-Misch- 

          Thank you for breaking out the solution. I had to remove one extra close parenthesis, but all else worked great.

 

Final code:

 

UpdateContext({NewSurvey:Patch(Responses,Defaults(Responses), {ResponseId:Text(CountRows(Responses)+1), Answer1:Radio1.Selected.OptionText,Answer2:Replace(Concat(Listcollect,OptionText & ", "),Len(Concat(Listcollect,OptionText & ", "))-1,1," "),Answer3:Text(Slider1.Value), Answer4:If(Radio1_1.Selected.OptionText="No","No," & TextInput1.Text,Radio1_1.Selected.OptionText),Answer5:TextInput1_1.Text,Username:User().FullName})});Navigate(Finish_Screen,ScreenTransition.Fade)

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

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (40,180)