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 / How to set global vari...
Power Apps
Unanswered

How to set global variable to a number Value and a text Value?

(0) ShareShare
ReportReport
Posted on by 201

Dear all:

I am newer for power  apps, would you please help me for global variable?

I would like to set a global variable "level"  to a number value and a gloal variable "ApprvalStatus" as text value.

The level initial value =1

I need to change level value and let level =level+1 and "ApprovalStatus" as text card input

 

How to set global variables?

 

Thanks a lot:)

Categories:
I have the same question (0)
  • Verified answer
    WillPage Profile Picture
    2,307 Super User 2025 Season 2 on at

    Set(variableName,1) then to increment, Set(variableName,variableName + 1)
    String value just Set(otherVariableName,"Value")

  • Jackywei_BDF Profile Picture
    201 on at

    @WillPage :

     

    Thanks for your support.

    I am working on power apps canvas application, does it work for number variable?

    By the way, do you know how to update sharepoint list specific column by patch function and keep others reqiured info  columns no change?

     

    Thanks a lot:)

     

  • WillPage Profile Picture
    2,307 Super User 2025 Season 2 on at

    @Jackywei_BDFyou can do this by going With({myRecord: LookUp('My List', ID = 1)}, Patch('My List',myRecord,{Title:myRecord.Title, 'Required Column': myRecord.'Required Column', 'Changed Column': "New Value"))

    Use whatever expression in the LookUp function to get the row in question. If you already have this record somewhere, such as Gallery1.Selected you can skip the With() function and just refer to Gallery1.Selected.'Required Column' when patching.

    Personally, whenever I'm patching a record I do it within a Set() for UpdateContext() so there's always an object variable with the exiting values in.

    e.g Set(myRecord, Patch('My List', Defaults('My List'), {Title:"My Item", 'Required Column':"Required Value"}))
    Now there's an object variable in memory so next patch can be
    Set(myRecord, Patch('My List', myRecord, {Title:myRecord.Title, 'Required Column':myRecord.'Required Column', 'Changed Column': "New Value"}))

  • white_knight Profile Picture
    47 on at

    Help ...

    It looks like you can only use the Set() function in a behaviour 

    In my case I would like to have global variable, globalvar_currentuser, that is set to the currentuser() but ideally this should be set when the application starts. 

    I then have an admin screen where I use a dropdown list box which should update the global value using the onchange property 

     

    struggling to get this to work, but in short I want some way to impersonate the logged in user for administration purposes.

     

    Any help much apricated  

  • WillPage Profile Picture
    2,307 Super User 2025 Season 2 on at

    @white_knight  The User() object in PowerApps has a particular schema you'll need to replicate. The properties of the User() object are Email, FullName and Image.

     

    So, as you already know, you can set the current user on app start with Set(current_user, User())

     

    Assuming you're using the Office365Users.SearchUserV2({searchTerm:Self.SearchText}).value for the items of your combo box, then your OnChange should look like this:

    Set(
     current_user,
     {
     Email: Self.Selected.Mail,
     FullName: Self.Selected.DisplayName,
     Image: Office365Users.UserPhotoV2(Self.Selected.Id)
     }
    )

     

  • white_knight Profile Picture
    47 on at

    @WillPage  , many thanks for taking the time out to look at this for me.

     

    I think it was the "on app start " that was the root of my issue as this was not getting set when I test. I only noticed then when I restarted Powerapps canvas editor.  Also school boy errors as I had sent so long trying different approaches that I was referring to a label value rather than using user().FullName which I must of used else where.

     

    In short all working so thank you for getting me back on track.

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard