Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
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);
        }
  • v-qiaqi@microsoft.com Profile Picture
    on at
    Re: (SHOULD BE EASY) Quick Create Form Clear Lookup

    Hi @MagoosClues,

    Thanks for your sharing.

  • Verified answer
    DC-23051928-0 Profile Picture
    31 on at
    Re: (SHOULD BE EASY) Quick Create Form Clear Lookup

    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);  
            }
        }
  • DC-23051928-0 Profile Picture
    31 on at
    Re: (SHOULD BE EASY) Quick Create Form Clear Lookup

    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);
            }

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 87 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 71 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 65 Super User 2025 Season 1

Overall leaderboard