cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dudditz
Continued Contributor
Continued Contributor

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
v-yutliu-msft
Community Support
Community Support

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
Continued Contributor
Continued Contributor

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
Continued Contributor
Continued Contributor

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
Continued Contributor
Continued Contributor

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (3,124)