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

Announcements

News and Announcements icon
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
    Microsoft Employee 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard