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 / (SHOULD BE EASY) Quick...
Power Apps
Answered

(SHOULD BE EASY) Quick Create Form Clear Lookup

(0) ShareShare
ReportReport
Posted on by 31
Hello People,
 
I have a Quick Create form in a model driven application.
A user has a choice, and depending on the choice, I set the visibility of a 2 lookup fields.
 
The issue is, if the person selects a value in a look up, but changes their mind and changes the choice, that look up field value remains...
MagoosClues_0-1709909330847.png

 

MagoosClues_1-1709909356315.png

 

MagoosClues_2-1709909480594.png

 

 

How can I clear this field?  
       
if (selectedValue !== 848660000) {
            // Case when selectedValue is not 848660000
            generalRevenueSourceControl.setVisible(false);
            generalRevenueSourceControl.getAttribute().setValue(null); // I need to clear the lookup field value
            grantSourceControl.setVisible(true);
        } else {
            // Case when selectedValue is 848660000
            generalRevenueSourceControl.setVisible(true);
            generalRevenueSourceControl.getAttribute().setValue(null); // I need to clear the lookup field value
            grantSourceControl.setVisible(false);
        }
I have the same question (0)
  • DC-23051928-0 Profile Picture
    31 on at

    I mistakenly put wrong code with obvious issues but here is the current code.

     
            if (selectedValue !== 848660000) {
                // Case when selectedValue is not 848660000
                generalRevenueSourceControl.getAttribute().setValue(null);  // I need to clear the lookup field value
                generalRevenueSourceControl.setVisible(false);
                grantSourceControl.setVisible(true);
            } else {
                // Case when selectedValue is 848660000
                grantSourceControl.getAttribute().setValue(null); // I need to clear the lookup field value
                grantSourceControl.setVisible(false);
                generalRevenueSourceControl.setVisible(true);
            }
  • Verified answer
    DC-23051928-0 Profile Picture
    31 on at

    After talking to my rubber duck, I figured this out...

    Like I said.. should be easy.  

    My logic was off, I had to set the fields to null outside the 'selctedValue' if statement..  

     

        if (typeAttribute) {
            var selectedValue = typeAttribute.getValue();
            generalRevenueSourceControl.getAttribute().setValue(null);
            grantSourceControl.getAttribute().setValue(null);

            if (selectedValue !== 848660000) {
                // Case when selectedValue is not 848660000
                generalRevenueSourceControl.setVisible(false);
                grantSourceControl.setVisible(true);
            } else {
                grantSourceControl.setVisible(false);
                generalRevenueSourceControl.setVisible(true);  
            }
        }
  • v-qiaqi@microsoft.com Profile Picture
    on at

    Hi @MagoosClues,

    Thanks for your sharing.

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