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

Lookup and Load a user record from CDS into powerApps Form

Hi, I have a powerApp form that I want load a specific user record from CDS and also the ability to update the record according to that user authentication.

 

Currently I have a Gallery that display a list of Questions and user can select "Yes or No"

In CDS i have a record of all users responses for example:

s.PNG

q.PNG

 

Question: how do I read the record in CDS so that the "yes/no" toggle change according to the question number?

how do I update the record when the user change or update the "yes/no" toggle?

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Dual Super User
Dual Super User

Re: Lookup and Load a user record from CDS into powerApps Form

Hi @WaMCHCH 

 

Assumptions:

Yes/No column type is CDS is the "Two Options" data type

 

The Gallery showing question from the data source

 

then set the default property of the yes no field as

If(ThisItem.'ColumnName2Option'='ColumnName2Option (datasource)'.Yes,true,false)

ColumnName2Option - name of the column in CDS

datasource - name of your data source

 

In example below - 101 is the name of the column and questions is the name of the data source

Capture.PNG

 

Regards,

Reza Dorrani

 

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

Community Support Team
Community Support Team

Re: Lookup and Load a user record from CDS into powerApps Form

Hi @WaMCHCH ,

Could you please share a bit more about the 101, 102, ... columns in your CDS Entity? Are they 'Two Options' column or 'Option Set' column in your CDS Entity?

Do you want to load record from your CDS Entity into Question Gallery based on the specific UserID?

Further, could you please show more details about the formula you typed within the Items property of the Gallery?

 

I assume that you want to load record from your CDS Entity into Question Gallery based on the specific UserID, is it true? I have made a test on my side, please take a try with the following workaround:

1. If the 101, 102, ... columns are all 'Two Options' column in your CDS Entity:

Within you Questions Gallery, set the Default property of the Toggle control to following:

If(
QuestionNumberBox.Text = "101", /* <-- QuestionNumberBox represents the Label in your Gallery to display the Question number value */ If(LookUp('YourCDSEntity', UserID ="Specific User ID").101 = '101 (YourEntityName)'.yes, true, false),
QuestionNumberBox.Text = "102",
If(LookUp('YourCDSEntity', UserID ="Specific User ID").102 = '102 (YourEntityName)'.yes, true, false),
QuestionNumberBox.Text = "103",
If(LookUp('YourCDSEntity', UserID ="Specific User ID").103 = '103 (YourEntityName)'.yes, true, false),
...
... )

2.  If the 101, 102, ... columns are all 'Option Set' column in your CDS Entity:

Within you Questions Gallery, set the Default property of the Toggle control to following:

If(
QuestionNumberBox.Text = "101", If(LookUp('YourCDSEntity', UserID ="Specific User ID").101 = [@101].yes, true, false),
QuestionNumberBox.Text = "102",
If(LookUp('YourCDSEntity', UserID ="Specific User ID").102 = [@102].yes, true, false),
QuestionNumberBox.Text = "103",
If(LookUp('YourCDSEntity', UserID ="Specific User ID").103 = [@103].yes, true, false),
...
... )

 

In addition, if you want to update the 101, 102, 103, ... column when you switch the Toggle control in your Gallery, please set the OnSelect property to following:

If(
    Toggle1.Value = true,
If(
QuestionNumberBox.Text = "101",
Patch(
'YourCDSEntity',
LookUp('YourCDSEntity', UserID ="Specific User ID"),
{
101: '101 (YourEntityName)'.yes
}
),
QuestionNumberBox.Text = "102",
Patch(
'YourCDSEntity',
LookUp('YourCDSEntity', UserID ="Specific User ID"),
{
102: '102 (YourEntityName)'.yes
}
),
...
...
),
If(
QuestionNumberBox.Text = "101",
Patch(
'YourCDSEntity',
LookUp('YourCDSEntity', UserID ="Specific User ID"),
{
101: '101 (YourEntityName)'.no
}
),
QuestionNumberBox.Text = "102",
Patch(
'YourCDSEntity',
LookUp('YourCDSEntity', UserID ="Specific User ID"),
{
102: '102 (YourEntityName)'.no
}
),
...
...
) )

More details about updating a Option Set type column in CDS, please check and see if the following blog would help in your scenario:

https://powerapps.microsoft.com/en-us/blog/option-sets-and-many-to-many-relationships-for-canvas-app...

More details about the Patch function, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

 

Best regards,

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.

View solution in original post

4 REPLIES 4
Highlighted
Dual Super User
Dual Super User

Re: Lookup and Load a user record from CDS into powerApps Form

Hi @WaMCHCH 

 

Assumptions:

Yes/No column type is CDS is the "Two Options" data type

 

The Gallery showing question from the data source

 

then set the default property of the yes no field as

If(ThisItem.'ColumnName2Option'='ColumnName2Option (datasource)'.Yes,true,false)

ColumnName2Option - name of the column in CDS

datasource - name of your data source

 

In example below - 101 is the name of the column and questions is the name of the data source

Capture.PNG

 

Regards,

Reza Dorrani

 

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

Community Support Team
Community Support Team

Re: Lookup and Load a user record from CDS into powerApps Form

Hi @WaMCHCH ,

Could you please share a bit more about the 101, 102, ... columns in your CDS Entity? Are they 'Two Options' column or 'Option Set' column in your CDS Entity?

Do you want to load record from your CDS Entity into Question Gallery based on the specific UserID?

Further, could you please show more details about the formula you typed within the Items property of the Gallery?

 

I assume that you want to load record from your CDS Entity into Question Gallery based on the specific UserID, is it true? I have made a test on my side, please take a try with the following workaround:

1. If the 101, 102, ... columns are all 'Two Options' column in your CDS Entity:

Within you Questions Gallery, set the Default property of the Toggle control to following:

If(
QuestionNumberBox.Text = "101", /* <-- QuestionNumberBox represents the Label in your Gallery to display the Question number value */ If(LookUp('YourCDSEntity', UserID ="Specific User ID").101 = '101 (YourEntityName)'.yes, true, false),
QuestionNumberBox.Text = "102",
If(LookUp('YourCDSEntity', UserID ="Specific User ID").102 = '102 (YourEntityName)'.yes, true, false),
QuestionNumberBox.Text = "103",
If(LookUp('YourCDSEntity', UserID ="Specific User ID").103 = '103 (YourEntityName)'.yes, true, false),
...
... )

2.  If the 101, 102, ... columns are all 'Option Set' column in your CDS Entity:

Within you Questions Gallery, set the Default property of the Toggle control to following:

If(
QuestionNumberBox.Text = "101", If(LookUp('YourCDSEntity', UserID ="Specific User ID").101 = [@101].yes, true, false),
QuestionNumberBox.Text = "102",
If(LookUp('YourCDSEntity', UserID ="Specific User ID").102 = [@102].yes, true, false),
QuestionNumberBox.Text = "103",
If(LookUp('YourCDSEntity', UserID ="Specific User ID").103 = [@103].yes, true, false),
...
... )

 

In addition, if you want to update the 101, 102, 103, ... column when you switch the Toggle control in your Gallery, please set the OnSelect property to following:

If(
    Toggle1.Value = true,
If(
QuestionNumberBox.Text = "101",
Patch(
'YourCDSEntity',
LookUp('YourCDSEntity', UserID ="Specific User ID"),
{
101: '101 (YourEntityName)'.yes
}
),
QuestionNumberBox.Text = "102",
Patch(
'YourCDSEntity',
LookUp('YourCDSEntity', UserID ="Specific User ID"),
{
102: '102 (YourEntityName)'.yes
}
),
...
...
),
If(
QuestionNumberBox.Text = "101",
Patch(
'YourCDSEntity',
LookUp('YourCDSEntity', UserID ="Specific User ID"),
{
101: '101 (YourEntityName)'.no
}
),
QuestionNumberBox.Text = "102",
Patch(
'YourCDSEntity',
LookUp('YourCDSEntity', UserID ="Specific User ID"),
{
102: '102 (YourEntityName)'.no
}
),
...
...
) )

More details about updating a Option Set type column in CDS, please check and see if the following blog would help in your scenario:

https://powerapps.microsoft.com/en-us/blog/option-sets-and-many-to-many-relationships-for-canvas-app...

More details about the Patch function, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

 

Best regards,

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.

View solution in original post

WaMCHCH
Level: Powered On

Re: Lookup and Load a user record from CDS into powerApps Form

Hi Reza, thank you for your help, is there a way for me to not hard code the colum name in the formular?

 

For example, each questions has a question number,

Entity : "QUESTION"  {colum heading:   QuestionNumber, QuestionDescription } (a question number [101,102...] and a description)

Entity : "Response"   { colum heading:    employeeID, Q101, Q102, Q103....etc} (Q101,102 refer to the question Number of "Yes/No")

 

If(ThisItem.'ColumnName2Option'='ColumnName2Option (datasource)'.Yes,true,false)

If(ThisItem.L1QuestionNumber = '101 (L1EmployeeResponses)'.Yes, true,false)

 

Is there a way for me to not hardcode "101" as there are many column [101,102,103 - 167]

 

 

WaMCHCH
Level: Powered On

Re: Lookup and Load a user record from CDS into powerApps Form

Thank you. I've implemented what you suggested and it work! 

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 (Last 30 Days)
Users online (5,309)