cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dudditz
Level 8

Global Variables, Indicate when they run.

I have serveral global variables running on a screen level.  See below for examples.  I am seeing the global variables are processing before much of the data has been assembled within my display form on one of the screens so it has captured a blank value.  If I switch screens and go back to the screen with the variables they are working as expected.  I am guessing the issue is they are running before the data is populated, specifcially ServiceLineValue.Text 

Is there to specifically tell PowerApps not to process the Global Variable until Fields, A,B,C have been populated?

 

If(!IsBlank(ServiceLineValue.Text) &&
ServiceLineValue.Text = "Building Technology" && PstageValue.Text = "InProcess", Set(LibraryURL_V, "https://amengtest.sharepoint.com/sites/PRJ-BLD/BLDProjectsActive/") && Set(LibraryName_V, "BLD-Projects Active") && Set(SiteURL_V, "https://amengtest.sharepoint.com/sites/PRJ-BLD/") && Set(BLD_V, true));

If(!IsBlank(ServiceLineValue.Text) &&
ServiceLineValue.Text = "Building Technology" && PstageValue.Text = "Completed", Set(LibraryURL_V, "https://amengtest.sharepoint.com/sites/PRJ-BLD/BLDProjectsArchive/") && Set(LibraryName_V, "BLD-Projects Archive") && Set(SiteURL_V, "https://amengtest.sharepoint.com/sites/PRJ-BLD/") && Set(BLD_V, true));

4 REPLIES 4
Community Support Team
Community Support Team

Re: Global Variables, Indicate when they run.

Hi @Dudditz ,

Could you descibe more clealy about how do you process the Global Variable?

Just according to your description, I suggest you try If statement to prevent processing the Global Variable before Fields, A,B,C having been populated.

Try this formula:

If(!Is(FieldA.Text)&&!Is(FieldB.Text)&&!Is(FieldC.Text),
Set(Global Variable,....), //if Fields, A,B,C have been populated,process the Global Variable
Set(Global Variable,"")) //if Fields, A,B,C haven't been populated,set the Global Variable to empty value

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Dudditz
Level 8

Re: Global Variables, Indicate when they run.

Hello there,

 

I did add another IF statement however it's still a bit random in how often it works.  Can you please tell me if the If !IsBlank statement is actually indicating for it to wait to process the variables until these fields are populated or if its simply skipping setting the variables since the fields are blanks.  

 

If(
!IsBlank(ServiceLineValue.Text && PstageValue.Text) && ServiceLineValue.Text = "Construction Services" && PstageValue.Text = "InProcess",
Set(
LibraryURL_V,
"https://amengtest.sharepoint.com/sites/PRJ-CSV/CSVProjectsActive/"
) && Set(
LibraryName_V,
"CSV-Projects Active"
) && Set(
SiteURL_V,
"https://amengtest.sharepoint.com/sites/PRJ-CSV/"
) && Set(
CSV_V,
true
)

Dudditz
Level 8

Re: Global Variables, Indicate when they run.

I have done many tests and this is what I have concluded.  Most of the global variables I am settings make use of the PstageValue.text in some sort of way.  As seen below I am using an !IsBlank on this field as well however this does not seem to help.  What seems to be occuring is the two fields seen below, serviceline and PstageValue are both populated automatically by Dynamics upon app load based upon the selected record in Dynamics as this is an embedded powerapp, it populates these fields with the current serviceline and Pstage from the Dynamics Projects form you launch the powerapp from.  The service line is populated immediatly, within 1 second when you load the app and the variable seems to be capturing that however the Pstage value is populated around 2-3 seconds after application load and it seems like this is the reason the variables are not catching the value of the Pstage from within Dynamics.  I can take the same variables and set them on a button and they work, I can also switch screens and when returning to the main screen where these variables are set it works and all variables are capturing their intended values.

 

So it seems to me the Pstage is the problem here as its often not populated by the time the variables are executed.  

 

!IsBlank(ServiceLineValue.Text && PstageValue.Text) && ServiceLineValue.Text = "Construction Services" && PstageValue.Text = "InProcess",

Dudditz
Level 8

Re: Global Variables, Indicate when they run.

Another test,

 

Dumped all these global variables that are not running in time into a timer and they work after waiting 5 seconds so this does reconfirm my suspcision this is simply a timing issue.  Is this really the only way to get these to process correctly not capturing the blank values? 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,345)