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

Disable button based on yes/no. Conditional display on the yes/no cards causing problems

Hello All,

 

We created a survey using power apps.  The survey contains about 100 fields from a sharepoint list (45 Questions and 45 comments for each question).

Since the list was very long, we divided the questions into each screen and displayed only those questions based on a conditional logic.  A user selects checkoxes of which sections he would like to answer and the navigation has been set that way.

I am not using Edit form but created scrollable screens.

 

This worked fine.

 

The issue is displaying the details of the survey a user submitted. I am using a browse gallery and a details form to display the questions and comments.

The problem is if I am trying to put all the 100 fields in the details form, it won't work obviously or it would take along time to retrieve the records.

How can I display only those questions which have been answered by the user? Is there any better way to handle thi s situation without crashing the app. Is there a better way of filtering the records?

I am not sure if Visible property would help since I have to keep all the fields on the details form anyway.

 

Please let me know if you need any additional details from my end. 

3 REPLIES 3
tommyly
Level 8

Re: Disable button based on yes/no. Conditional display on the yes/no cards causing problems

If you have SharePoint, there is a native survey app that can do all of this for you:

image.png

 

If there is a specific reason why you created a list and want to then put it in an app to enhance the user experience, then I can think of at least 2 ways to do this (and I'm sure others can think of more):

 

Use PowerApps Forms

  1. Create one or a combination of columns as a hash (e.g. a column for User and a column for SubmissionTime)
  2. On screen1's OnVisible or OnStart event, create these values in advance:
    1. Set(varCurrentUser, User().FullName);
    2. Set(varSubmissionTime, Now())
  3. On screen1, create a form
    1. Set the form's DefaultMode to 'New'
    2. Select the appropriate questions per survey logic
    3. Include the User and SubmissionTime column/datacards
    4. Set the User datacard's Update field to local variable varCurrentUser
    5. Set the Submission datacard's Update field to local variable varSubmissionTime
    6. Set User and SubmissionTime datacard visibility false so that the user cannot see them
  4. Have a button or object to submit the form (to the user, this might intuitively be a "Next" button). To submit, use the syntax Submitform(myForm)
  5. On the form's OnSuccess event (on a successful submission), have it navigate to the next screen per survey logic.
  6. On the following screens, similarly create a form:
    1. Set its defaultmode to Edit
    2. Set Item property to Filter(mySurveyList, User=varCurrentUser, SubmissionTime=varSubmissionTime)
      1. This will ensure that you will be editing the same record
    3. Select the appropriate survey questions per survey logic
  7. Repeat step 6 for all subsequent question sets (per survey logic)

 

I didn't get into the nitty-gritty, but I hope that gives you a direction.

 

Community Support Team
Community Support Team

Re: Disable button based on yes/no. Conditional display on the yes/no cards causing problems

Hi @chsandeep,

Do you add a column within your SP list to store the user who submitted the survey?

Which data type is the Questions column in your SP list?

Further, do you want to display only those questions which have been answered by the user within the Detail form?

 

I agree with your thought almost, I think the Visible property of the Data card control within the Detail form could achieve your needs.

I assume that you add a column in your SP list to store the user (e.g. FullName, email, DisplayName, etc.) who submitted the survey, you could look up your SP list data source based on the current user, check if the corresponding question has been answered, if yes, make the corresponding Data card visible, if not, make the corresponding Data card invisible.

I have made a test on my side, please take a try with the following workaround:
Set the Visible property of the Question1 Data card within the Detail form to following:

If(
!IsBlank(
LookUp('YourSPList',UserName=User().Mail,Question1)
),
true,
false
)

Note: The UserName represents the column which is used to store the who submitted the survey within your SP list. The Question1 represents the first question field in your SP list.

Set the Visible property of the Question2 Data card within the Detail form to following:

If(
  !IsBlank(
      LookUp('YourSPList',UserName=User().Mail,Question2)
   ),
  true,
  false
)

Set the Visible property of the Question3 Data card within the Detail form to following:

If(
  !IsBlank(
      LookUp('YourSPList',UserName=User().Mail,Question3)
   ),
  true,
  false
)

...

Set the Visible property of the Question45 Data card within the Detail form to following:

If(
  !IsBlank(
      LookUp('YourSPList',UserName=User().Mail,Question45)
   ),
  true,
  false
)

More details about the LookUp function in PowerApps, please check the following article:

LookUp function

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
chsandeep
Level: Powered On

Re: Disable button based on yes/no. Conditional display on the yes/no cards causing problems

Thank you all for the suggestion. The reason for building a survey app was to enable the users to submit the answers online.

I was having an issue in the detail form to only display the questions that the users chose to answer.

 

I have achieved the solution by using the Visible property and diplaying only those fields which the user answered.

I have the details of the user name and email address.

 

For this, sine the dataset was large, I am using a collection to first collect the data from the SharePoint and then using the fields off of the collection. This way, I am not having an issue with the form being displayed without any lag or performance errors.

 

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 454 members 6,689 guests
Please welcome our newest community members: