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 / Conditional Formatting...
Power Apps
Unanswered

Conditional Formatting for LookUp Labels

(0) ShareShare
ReportReport
Posted on by

Hello, I am working on a new request form (screenshot attached). I have it set up so that when the user selects a Project Number from the dropdown control, the Project Name and Program Mgr/Product Engr labels are automatically populated via LookUp formulas. I kept the underlying text input controls in the data cards so the selections could be written back to my SharePoint list.

 

The current Text formula for the Project Name label is:

LookUp('Project List','Project Number' = ddProjectNumber.Selected.'Project Number','Project Name')

 

The current Text formula for the Program Mgr/Product Engineer label is:

LookUp('Project List','Project Number' = ddProjectNumber.Selected.'Project Number','Project Owner'.DisplayName)

 

When the user first launches the form, I would like the Project Name and Program Mgr/Product Engr labels to be disabled and read “Auto-populates based on Project Number selection”. Once the user has selected something from the Project Number dropdown control, that message should be replaced with the results of the LookUp and the label should be read-only as they don't want them to allow them to edit the results. I tried a If(IsBlank type formula, but didn’t get very far since I am still new at this. Can you please help me develop the correct syntax? Let me know if you need any additional information.

 

The other thing I should mention is that the new request form is on a dedicated screen of its own. When the user selects an item from the gallery to view or edit, they are taken to a separate screen with multiple tabs. Do I still need to include some type of If(frmNewRequest.Mode = FormMode.New, FORMULA, Parent.Default) type syntax in all of my new request form fields? If so, can you help me incorporate that piece into the LookUp labels as well? Thanks in advance for your kind assistance. Teresa

Categories:
I have the same question (0)
  • Verified answer
    faustocapellanj Profile Picture
    1,662 on at

    Hello @tagustin2020 

    This is how I would approach your scenario. On your drop-down OnChange property, enter a formula similar to this one: Set(varProjectInfo, LookUp(ProjectList, 'Project Number' = ddProjectNumber.Selected.'Project Number'). Once that's done, set the Text property of your Project Name label to varProjectInfo.'Project Name', and then set the Text property of your Program Mgr/Product Engineer label to varProjectInfo.'Project Owner'.DisplayName

    The reason for this approach is that the LookUp is pulling the entire record and the varProjectInfo variable will have all the columns available for use, i.e. varProjectInfo.'Project Name' and so on and so forth. Also, this will decrease the number of LookUp calls the form will execute, which prevents performance issues when having too many lookups.

    As for the other part of the app where the user selects a record from the gallery, don't use galleryname.Selected. Instead, if you are using a button to select the gallery item or you want to do it directly in the gallery's OnSelect property, set another variable similar to this code: Set(varRecord, ThisItem), then in the form's Item property, set its value to the varRecord variable.

    Please try these approaches and let me know.

    Regards,

  • tagustin2020 Profile Picture
    on at

    Hello Fausto,

     

    Thank you for the advice. I'm excited to try it. Our IT Dept is working on my computer so I may not have a chance to try this until tomorrow. I'll get back to you as soon as possible. Have a great weekend!

     

    Kind regards,

    Teresa

  • tagustin2020 Profile Picture
    on at

    Hello Fausto,


    Thanks again for responding to my inquiry. I entered the following formula into the OnChange property of my Project Number dropdown control which I named ddProjectNumber. Unfortunately, it is generating error messages. I notice that your formula is stated as ProjectList without spaces or apostrophes. Are you recommending that I create a Collection in the OnVisible of the New Screen form for the Project List? If so, seems like you would have entered a name of colProjectList, but I thought I should ask anyway. The Text property formulas aren't working either as intellisense is unable to find the list column names.

     

    Here is how I have the OnChange property currently set. Notice the apostrophes and spaces in 'Project List'. I tried entering it as ProjectList, but it doesn't work that way either.


    Set(varProjectInfo,LookUp('Project List','Project Number' = ddProjectNumber.Selected.'Project Number')


    I’ve attached a screenshot of the errors I am getting.

     

    While I welcome opportunities to make my app more performant, my original question was around how do I disable the two other fields until someone selects something from the dropdown. I don't want them to attempt entering information into those labels.

     

    In regards to your second piece of advice, I am already doing that, but thank you, it is great advice. 

     

    Kind regards,

    Teresa

  • faustocapellanj Profile Picture
    1,662 on at
    Hi Teresa, The ProjectList name in the formula was in reference to your formula, but I should've used the same name you have to avoid confusion. My apologies. When you execute the OnChange property of the drop-down, please to go to File > Variables and see if the varProjectInfo variable has a value in it. If it does, it should show you one record with multiple columns in it. These are the columns you can then use along with the variable as varProjectInfo.ColumnName. Can you please try that and let me know? Thank you!
  • tagustin2020 Profile Picture
    on at

    Hello Fausto,

     

    Thanks for getting back to me. Since the On Change formula is throwing errors it isn't possible to execute it, nothing is happening. I checked the Variables and there is nothing registered at this point. Any suggestions of what I should try next?

     

    Teresa

  • faustocapellanj Profile Picture
    1,662 on at

    Hi Teresa,

    Next thing I would try is to add a button and add the code to the button's OnSelect property. Then hard code an actual project number in the formula and see what that returns.

  • tagustin2020 Profile Picture
    on at

    Thank you Fausto. Do you have any thoughts on how I can achieve my original inquiry? If not, I'll mark your latest suggestion as a solution and will start a new ticket since this thread is getting long. Have a great day! Teresa

  • faustocapellanj Profile Picture
    1,662 on at

    Hi Teresa,

    No need to start a new thread. Since the app checker says there's an error in the formula, can you look at what the error is directly in the formula and then post it here? That way we know what the app is complaining about and fix it.

    Regards.

  • tagustin2020 Profile Picture
    on at

    Hi Fausto,

     

    I was able to set the variable this time. Turns out I was missing a parenthesis. I changed my Program Manager/Product Engineer to a people picker control and am not seeing an error when I enter varProjectInfo into the Default property of the data card, but I haven't been able to test it yet as I am still getting errors in the Project Name fields. The purpose of the text input field is to write the Project Name back to the SharePoint list. I tried doing this based off of just a label and was not successful.

     

    First, I tried entering varProjectInfo into the Text property of the label. I got this error.

    Expected Text Value.lblProjectName.Text

     

    I then tried entering varProjectInfo into the Default property of the text input and got this error.

    Expected Text Value.txtValueProjectName.Default

     

    Teresa

  • faustocapellanj Profile Picture
    1,662 on at
    Hi Teresa, For the labels you are trying to use, have you changed the Update property of the data card to have that label as the source of the desired value?

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard