cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
leonardbd
Helper III
Helper III

PowerApps Global Variable conflicting on defining as Gallery Item

Hello everyone,

 

I'm having issue in folowoing scenario while defining global variable to Gallery Item.

 

I have defined a global variable on Screen OnStart event as "VarItemX". It gets the ItemID parameter from a flow Email link that has Deep Linking and define the record ID as VarItemX variable. Such as record number 274. When user access the link from email, it start the app and navigates to the specific Screen (AdminApproveScreen) and load the data (record 274) on that screen. The screen has a Gallery with Item event/property defied as the variable "VarItemX". It works fine

 

If(
    !IsBlank(Param("ItemID")),
    Set(
        VarItemX,
        LookUp(
            'Exit Clearance V02',
            ID = Value(Param("ItemID"))
        )
    );
    Set(
        VArFormMode,
        FormMode.Edit
    )
)

 NOw I have another screen (called AllRequests) with a Data Table (called Table_AllRequests) where user can select the record from the table and load the specific screen ( AdminApprove) which will load the Item selected in that data table. Following is the Code applied on Button OnSelect event.

Set(VarApprover, User().Email);
If(VarApprover = Table_AllRequests.Selected.Adm2ApproverEmail,
Navigate(
    AdminApprove,
    ScreenTransition.Fade,
    {VarItemX: Table_AllRequests.Selected}
));

But in above formula if I use the Global Variable "VarItemX" as selected record from that data table, it conflicts with the Variable that defined at the Screen OnStart event. And the screen that I am trying to land the user from Email deep link or from this data table is not properly loading the Item in the gallery of that screen from Variable "VarItemX". It load the data If I select from data Table but didn't load the data in the same screen Gallery from the Email Deep link.

I'm not sure how to achieve that. Should I define two different Variable for Data Table selection and Email Deep link and assign the Item with two different variable with IF condition... I'm not sure how to proceed. 

I can upload the screen recording if it sounds a bit complicated. 

Need your expert advice on this issue.

13 REPLIES 13

Hi Warren, another modification required on above formula.

 

When an approver selecting a record from table All_Request it is loading the specific screen with record VaritemX. That is working fine. 

But if the Approver goes away for a leave without approving after submitting the request, a new approver listed in the Approver List table ('ExitCL02-Approvers') should be able to approve the specific request. 

In our formula as we are matching logged-in user with approver email in the specific record not from approver list, the new approver will not be able to land in that specific screen for that specific request.  To let the approver land in to his specific screen we need to match logged in user with 'ExitCL02-Approvers' table. The formula may goes like this, but it isn't working. I Have commented the previous for your reference.

 

 

Set(
   VarItemX, 
   Table_AllRequests.Selected
);
With(
   {
      wScreen:
      Switch(
         User().Email,
         VarItemX.Supervisor.Email,
         SupervisorApprove,
         //VarItemX.Adm2ApproverEmail,
         'Exit Clearance V02',Name.Email && category.value = "Admin"       
         AdminApprove,
         //VarItemX.Fin2ApproverEmail,
         'Exit Clearance V02',Name.Email && category.value = "Finance"  
         FinanceApprove,
         //VarItemX.ICT2ApproverEmail,
         'Exit Clearance V02',Name.Email && category.value = "ICT"  
         ICTApprove,
         //VarItemX.Sec2ApproverEmail,
         'Exit Clearance V02',Name.Email && category.value = "Security" 
         SecurityApprove,
         //VarItemX.HR2ApproverEmail,
         'Exit Clearance V02',Name.Email && category.value = "HR" 
         HRApprove,
         YourDefaultScreen
      )
   },
   Navigate(
      wScreen,
      ScreenTransition.Fade
   )
);

 

 

It is the Request list name. 

Hi @leonardbd ,

But what is 'Exit Clearance V02' (is it a field or a variable and what type) ?

leonardbd
Helper III
Helper III

Sorry Warren, 

I have two SP list, One is 'Exit Clearance V02'  that keep all clearance requests. Another is 'ExitCL02-Approvers' where all approvers are listed. In previous formula, Switch statement matching logged-in users email with  'Exit Clearance V02' 's filed such as Adm2ApproverEmail in specific record in VarItemX variable.

But I would like to match the logged-in user with filed Name.Email of 'ExitCL02-Approvers' list and  with filed Category="Admin"  instead of 'Exit Clearance V02' list's specific record. 

Hope you have got it. My code is following and I have commented the previous code for your understanding.

Set(
   VarItemX, 
   Table_AllRequests.Selected
);
With(
   {
      wScreen:
      Switch(
         User().Email,
         VarItemX.Supervisor.Email,
         SupervisorApprove,
         //VarItemX.Adm2ApproverEmail,
         'Exit Clearance V02',Name.Email && category.value = "Admin"       
         AdminApprove,
         //VarItemX.Fin2ApproverEmail,
         'Exit Clearance V02',Name.Email && category.value = "Finance"  
         FinanceApprove,
         //VarItemX.ICT2ApproverEmail,
         'Exit Clearance V02',Name.Email && category.value = "ICT"  
         ICTApprove,
         //VarItemX.Sec2ApproverEmail,
         'Exit Clearance V02',Name.Email && category.value = "Security" 
         SecurityApprove,
         //VarItemX.HR2ApproverEmail,
         'Exit Clearance V02',Name.Email && category.value = "HR" 
         HRApprove,
         YourDefaultScreen
      )
   },
   Navigate(
      wScreen,
      ScreenTransition.Fade
   )
);

Now it isn't working. Not sure why.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,374)