web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Lookup and Load a user...
Power Apps
Answered

Lookup and Load a user record from CDS into powerApps Form

(0) ShareShare
ReportReport
Posted on by 26

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?

 

Categories:
I have the same question (0)
  • Verified answer
    RezaDorrani Profile Picture
    12,143 on at

    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

     

  • Verified answer
    v-xida-msft Profile Picture
    on at

    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-apps/

    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,

  • WaMCHCH Profile Picture
    26 on at

    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 Profile Picture
    26 on at

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard