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 / I cannot set a variabl...
Power Apps
Answered

I cannot set a variable of any kind in my app

(0) ShareShare
ReportReport
Posted on by 63
I have a legacy app written over the last two years.  Warren helped me recently when I couldn't set a collection.  I've had to create and hide text input boxes populating them with results from user input from different boxes in order for it to ClearCollect (or Collect).
 
Now this doesn't work (in a Button, OnSelect):
 
Set(
    varActSubSel,
    txtActSubSel.Text
);
ClearCollect(
    colSelVios,
    (SortByColumns(
        Filter(
            SubViolations,
            ViolationDate = varSelDate And Title = varProjectTitle And ActSubName = varActSubSel //("Big D Roofing")
        ),
        "ActSubName",
        SortOrder.Descending
    ))
)
 
txt.ActSubSel.Text = "Big D Roofing", but varActSubSel will not set
 
Thus the ClearCollect won't work.
 
Directly typing "Big D Roofing" in place of varActSubSel will load the Filter, SortByColumns but the variable colSelVios will not load.
 
I'm lost.  I created a new project and made certain that all the setting are identical.  The same code within a button on a screen works.
 
I can also create a new screen in my app, and the same.  It works.
 
I stripped all the code from my pre-existing screen and replicated the working environment.  It will not load.
 
I have collections in many of my screens and they are all affected.
 
I have disconnected and reconnected the SP list.  Started and stopped the app leaving the environment.  Changed Powerapp versions forward to .16 and back two weeks when it was certainly working.   Also restored from several older version of my app.  Nothing.
 
Has anyone had to start from scratch and completely rebuild because of this?
 
I have sh%&ton of code that will have to be re-written.
 
JP
Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    156,100 Most Valuable Professional on at
    Hi YetiSB6C 
    As you would agree, that does not make a whole lot of sense unless you have a Variable with the same name set with UpdateContext on the same screen (which will take precedent). However, why bother with the Variable?
    ClearCollect(
       colSelVios,
       SortByColumns(
          Filter(
             SubViolations,
             ViolationDate = varSelDate And Title = varProjectTitle And ActSubName = txtActSubSel.Text
          ),
          "ActSubName",
          SortOrder.Descending
       )
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

     
  • CU23011914-0 Profile Picture
    63 on at
    Warren:

    No UpdateContext variable.  But I totally agree that it would have been the problem.  Good knowledge! 

    The code above was the total for the entire screen - in a button. I did have a Gallery for the result, but the new screens that worked did as well.
     
    It's fine today.  Yesterday, even my live version was writing blank fields to SP List required columns.  I think the SP updates were so slow it made it look like the variables were not set(?).
     
    Not sure lag explains successful Filter, ShowByColumns, LookUp, and yet no Collect or Set capability anywhere.   Except in brand new trial screens.
     
    Today no issues in either environment.  Still on .15 which is recommended.  I tried other version but they wouldn't stay set.
     
    I didn't make many changes so I only lost a day.  I'm back to where I started yesterday am.
     
    Thanks again,
     
    JP
     
    P.S. Enjoy the coffee!

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard