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 / remove global variable
Power Apps
Unanswered

remove global variable

(1) ShareShare
ReportReport
Posted on by 13

I have 2 variables set to two lookup functions. If the lookup function tally with the user credentials enters in the text box it navigates to a screen called admin. I want to remove one variable at a successful login and keep only the successful login variable.

 

If(
    IsBlank(LookUp(UserTR, Title = TextInput1.Text And passwordtr = TextInput1_1.Text)),
    Notify("User Name & Password Incorrect", NotificationType.Error),
    With(
        { userrecord1: LookUp(UserTR, Title = TextInput1.Text And passwordtr = TextInput1_1.Text) },
        Switch(
            userrecord1.roletr.Value,
            "QA", Navigate(AdminScreen),
            "mecha", Navigate(AdminScreen),
            "BD", Notify("Role not found", NotificationType.Error))
            && Set(ss1,userrecord1.roletr.Value)

    )

     
   
);

If(
    !IsBlank(LookUp(UserL1, Title = TextInput1.Text And passwordl1 = TextInput1_1.Text)),
    With(
        { userrecord2: LookUp(UserL1, Title = TextInput1.Text And passwordl1 = TextInput1_1.Text) },
        Switch(
            userrecord2.rolel1.Value,
            "IT", Navigate(AdminScreen),
            "HR", Navigate(AdminScreen),
            "gh", Notify("Role not found", NotificationType.Error)
        ) && Set(sss,userrecord2.rolel1.Value)

    )    
     
);



Categories:
  • Pstork1 Profile Picture
    69,665 Most Valuable Professional on at

    I don't think there is currently any way to actually remove the variable definition entirely. But you can set the value of the Context variable you don't want to Blank(). This will basically set the variable to a Null value. Although the variable will still be there, there will be no value associated with it.

  • yurigagari Profile Picture
    13 on at

    sorry i didn't understand the point.

  • Pstork1 Profile Picture
    69,665 Most Valuable Professional on at

    to remove the value of context variable called userrecord2 you can use the following formula.

    UpdateContext({userrecord2: Blank()})

    But since you are creating it in a With() function it should go away once you are outside the scope of the With.

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 194 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 150

Last 30 days Overall leaderboard