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

Leave Request Template - Edit types of Leave

Hello all,

 

We are in the process to deply the PowerApps template of Leave requests within our org.

Can you please assist me on how to remove completely from the template some leave types?

 

From the OnStart i've left only the below

 

 

LeaveTypeCollection, 
        Table(
                {
                    type:"Vacation Leave", 
                    icon:vacation,
                    iconselected:'vacation-selected',
                    description:
                    "Vacation leave is provided to all employees for the purpose of rest, relaxation, and to attend to personal affairs. Vacation balance is acquired over time and can be used at any time."
                }
                ,
                {
                    type:"Sick Leave", 
                    icon:'sick-leave', 
                    iconselected:'sick-leave-selected',
                    description:"Sick leave may be used for your own illness or medical/dental appointments or for the illness or medical/dental appointments of family members. Sick leave can also be used to address the psychological, physical, or legal aspects of domestic violence, sexual assault, stalking, or other crime. You may not use sick leave for vacation purposes. Some cities and states have specific laws governing sick leave that allow use of sick leave to care for other family members."
                }

 

 

 

On 'About' section and on New request i can see only these two types,

BUT, on 'My Leave Balance' all types are visible.

1 ACCEPTED SOLUTION

Accepted Solutions

My bad, here are the additional changes you need to make:

1. HomeScreen -> OnVisible

Concurrent(
    Set(_navMenuSelect, "My Leave Requests"),
    //if not manager view, refresh my balance collection when on this screen
    If(!_managerView, Set(_requesterBalanceRecord, LookUp(BalanceCollection, Year = Text(Year(Now())) && EmployeeEmail = _myProfile.UserPrincipalName));
        ClearCollect(RequesterBalanceCollection, 
        { type: "Vacation", balance: Value(_requesterBalanceRecord.Vacation) - Value(_requesterBalanceRecord.VacationUsed)},
        {type:"Sick Leave", balance:Value(_requesterBalanceRecord.Sick)-Value(_requesterBalanceRecord.SickUsed)}/*,
        {type:"Floating Holiday", balance:Value(_requesterBalanceRecord.Floating)-Value(_requesterBalanceRecord.FloatingUsed)},
        {type:"Jury Duty", balance:Value(_requesterBalanceRecord.JuryDuty)-Value(_requesterBalanceRecord.JuryDutyUsed)},
        {type:"Bereavement", balance:Value(_requesterBalanceRecord.Bereavement)-Value(_requesterBalanceRecord.BereavementUsed)}*/)
    ),
    Set(_showDetails, false)
);

 

2. HomeScreen -> BtnManagerApprove

Concurrent(
    Set(_submittingRequest, true),
    //when approving leave, add the respective days used to the respective used days field
    Patch(BalanceCollection, LookUp(BalanceCollection, BalanceID =  _requesterBalanceRecord.BalanceID),
        If(Upper(GalleryRequests.Selected.LeaveType) = Upper("Vacation"), {VacationUsed: _requesterBalanceRecord.VacationUsed + _requestedDays},
        Upper(GalleryRequests.Selected.LeaveType) = Upper("Sick leave"), {SickUsed: _requesterBalanceRecord.SickUsed + _requestedDays}/*,
        Upper(GalleryRequests.Selected.LeaveType) = Upper("Floating holiday"), {FloatingUsed: _requesterBalanceRecord.FloatingUsed + _requestedDays},
        Upper(GalleryRequests.Selected.LeaveType) = Upper("Jury duty"), {JuryDutyUsed: _requesterBalanceRecord.JuryDutyUsed + _requestedDays},
        Upper(GalleryRequests.Selected.LeaveType) = Upper("Bereavement"), {BereavementUsed: _requesterBalanceRecord.BereavementUsed + _requestedDays}*/
        )
    ),
    Set(_managerApprove, true));
Patch(LeaveCollection, LookUp(LeaveCollection, LeaveID = GalleryRequests.Selected.LeaveID), {Status: "Approved"});
Set(_submittingRequest, false);
Navigate(ManagerChangeRequestScreen, None);
      

 

3. LeaveBalanceScreen -> OnVisible

Concurrent(
    Set(_navMenuSelect, "My Leave Balance"),
    ClearCollect(RequesterBalanceCollection, 
    { type: "Vacation", balance: Value(_requesterBalanceRecord.Vacation) - Value(_requesterBalanceRecord.VacationUsed)},
    {type:"Sick Leave", balance:Value(_requesterBalanceRecord.Sick)-Value(_requesterBalanceRecord.SickUsed)}/*,
    {type:"Floating Holiday", balance:Value(_requesterBalanceRecord.Floating)-Value(_requesterBalanceRecord.FloatingUsed)},
    {type:"Jury Duty", balance:Value(_requesterBalanceRecord.JuryDuty)-Value(_requesterBalanceRecord.JuryDutyUsed)},
    {type:"Bereavement", balance:Value(_requesterBalanceRecord.Bereavement)-Value(_requesterBalanceRecord.BereavementUsed)}*/
   )
)

 

4. ManagerChangeRequestScreen -> OnVisible

Concurrent(
    Set(_navMenuSelect, "My Leave Balance"),
    ClearCollect(RequesterBalanceCollection, 
    { type: "Vacation", balance: Value(_requesterBalanceRecord.Vacation) - Value(_requesterBalanceRecord.VacationUsed)},
    {type:"Sick Leave", balance:Value(_requesterBalanceRecord.Sick)-Value(_requesterBalanceRecord.SickUsed)}/*,
    {type:"Floating Holiday", balance:Value(_requesterBalanceRecord.Floating)-Value(_requesterBalanceRecord.FloatingUsed)},
    {type:"Jury Duty", balance:Value(_requesterBalanceRecord.JuryDuty)-Value(_requesterBalanceRecord.JuryDutyUsed)},
    {type:"Bereavement", balance:Value(_requesterBalanceRecord.Bereavement)-Value(_requesterBalanceRecord.BereavementUsed)}*/
   )
)

 

5. ManagerSendEmailScreen -> OnVisible

Concurrent(
    Set(_navMenuSelect, "My Leave Balance"),
    ClearCollect(RequesterBalanceCollection, 
    { type: "Vacation", balance: Value(_requesterBalanceRecord.Vacation) - Value(_requesterBalanceRecord.VacationUsed)},
    {type:"Sick Leave", balance:Value(_requesterBalanceRecord.Sick)-Value(_requesterBalanceRecord.SickUsed)}/*,
    {type:"Floating Holiday", balance:Value(_requesterBalanceRecord.Floating)-Value(_requesterBalanceRecord.FloatingUsed)},
    {type:"Jury Duty", balance:Value(_requesterBalanceRecord.JuryDuty)-Value(_requesterBalanceRecord.JuryDutyUsed)},
    {type:"Bereavement", balance:Value(_requesterBalanceRecord.Bereavement)-Value(_requesterBalanceRecord.BereavementUsed)}*/
   )
)

 

I tested this out so it should work. But let me know if it doesn't. 

 

---
If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

 

Thanks!

Hardit Bhatia

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

 

 

View solution in original post

15 REPLIES 15
PowerAddict
Super User
Super User

Did you Save and Publish your app? Or within your editor did you click on the 3 dots next to the App and select Run OnStart? 

 

Also, if not for anything else but to keep it clean, I would remove those leave types from this collection as well: 

ClearCollect(BalanceCollection,
        {
            EmployeeEmail: _myProfile.UserPrincipalName, 
            EmployeeName: _myProfile.DisplayName , 
            Year: Text(Year(Now())), 
            Vacation:10, 
            VacationUsed:0, 
            Sick:8, 
            SickUsed:0, 
            Floating:8, 
            FloatingUsed:0, 
            JuryDuty:3, 
            JuryDutyUsed:0, 
            Bereavement:5, 
            BereavementUsed:0, 
            BalanceID:_myProfile.UserPrincipalName&Text(Now(), "[$-en-US]mm-dd-yyyy-hh-mm-ss-fff")
        }
)

 

Let me know if these changes work out for you. 

 

---
If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

 

Thanks!

Hardit Bhatia

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

Hello @PowerAddict  and thanks for your reply.

I have already removed your suggested and left only the below

 

 LookUp(Balance, Year = Text(Year(Now())) && EmployeeEmail = _myProfile.UserPrincipalName)),
            Patch(Balance, Defaults(Balance),
            {
                EmployeeEmail: _myProfile.UserPrincipalName, 
                EmployeeName: _myProfile.DisplayName, 
                Year: Text(Year(Now())), 
                Vacation:15, 
                VacationUsed:0, 
                Sick:8, 
                SickUsed:0, 
                BalanceID:_myProfile.UserPrincipalName&Text(Now(), "[$-en-US]mm-dd-yyyy-hh-mm-ss-fff")
            }
        )
    ),

 

But on 'My leave balance' section, all template's default types of leaves are visible.

 

My bad, here are the additional changes you need to make:

1. HomeScreen -> OnVisible

Concurrent(
    Set(_navMenuSelect, "My Leave Requests"),
    //if not manager view, refresh my balance collection when on this screen
    If(!_managerView, Set(_requesterBalanceRecord, LookUp(BalanceCollection, Year = Text(Year(Now())) && EmployeeEmail = _myProfile.UserPrincipalName));
        ClearCollect(RequesterBalanceCollection, 
        { type: "Vacation", balance: Value(_requesterBalanceRecord.Vacation) - Value(_requesterBalanceRecord.VacationUsed)},
        {type:"Sick Leave", balance:Value(_requesterBalanceRecord.Sick)-Value(_requesterBalanceRecord.SickUsed)}/*,
        {type:"Floating Holiday", balance:Value(_requesterBalanceRecord.Floating)-Value(_requesterBalanceRecord.FloatingUsed)},
        {type:"Jury Duty", balance:Value(_requesterBalanceRecord.JuryDuty)-Value(_requesterBalanceRecord.JuryDutyUsed)},
        {type:"Bereavement", balance:Value(_requesterBalanceRecord.Bereavement)-Value(_requesterBalanceRecord.BereavementUsed)}*/)
    ),
    Set(_showDetails, false)
);

 

2. HomeScreen -> BtnManagerApprove

Concurrent(
    Set(_submittingRequest, true),
    //when approving leave, add the respective days used to the respective used days field
    Patch(BalanceCollection, LookUp(BalanceCollection, BalanceID =  _requesterBalanceRecord.BalanceID),
        If(Upper(GalleryRequests.Selected.LeaveType) = Upper("Vacation"), {VacationUsed: _requesterBalanceRecord.VacationUsed + _requestedDays},
        Upper(GalleryRequests.Selected.LeaveType) = Upper("Sick leave"), {SickUsed: _requesterBalanceRecord.SickUsed + _requestedDays}/*,
        Upper(GalleryRequests.Selected.LeaveType) = Upper("Floating holiday"), {FloatingUsed: _requesterBalanceRecord.FloatingUsed + _requestedDays},
        Upper(GalleryRequests.Selected.LeaveType) = Upper("Jury duty"), {JuryDutyUsed: _requesterBalanceRecord.JuryDutyUsed + _requestedDays},
        Upper(GalleryRequests.Selected.LeaveType) = Upper("Bereavement"), {BereavementUsed: _requesterBalanceRecord.BereavementUsed + _requestedDays}*/
        )
    ),
    Set(_managerApprove, true));
Patch(LeaveCollection, LookUp(LeaveCollection, LeaveID = GalleryRequests.Selected.LeaveID), {Status: "Approved"});
Set(_submittingRequest, false);
Navigate(ManagerChangeRequestScreen, None);
      

 

3. LeaveBalanceScreen -> OnVisible

Concurrent(
    Set(_navMenuSelect, "My Leave Balance"),
    ClearCollect(RequesterBalanceCollection, 
    { type: "Vacation", balance: Value(_requesterBalanceRecord.Vacation) - Value(_requesterBalanceRecord.VacationUsed)},
    {type:"Sick Leave", balance:Value(_requesterBalanceRecord.Sick)-Value(_requesterBalanceRecord.SickUsed)}/*,
    {type:"Floating Holiday", balance:Value(_requesterBalanceRecord.Floating)-Value(_requesterBalanceRecord.FloatingUsed)},
    {type:"Jury Duty", balance:Value(_requesterBalanceRecord.JuryDuty)-Value(_requesterBalanceRecord.JuryDutyUsed)},
    {type:"Bereavement", balance:Value(_requesterBalanceRecord.Bereavement)-Value(_requesterBalanceRecord.BereavementUsed)}*/
   )
)

 

4. ManagerChangeRequestScreen -> OnVisible

Concurrent(
    Set(_navMenuSelect, "My Leave Balance"),
    ClearCollect(RequesterBalanceCollection, 
    { type: "Vacation", balance: Value(_requesterBalanceRecord.Vacation) - Value(_requesterBalanceRecord.VacationUsed)},
    {type:"Sick Leave", balance:Value(_requesterBalanceRecord.Sick)-Value(_requesterBalanceRecord.SickUsed)}/*,
    {type:"Floating Holiday", balance:Value(_requesterBalanceRecord.Floating)-Value(_requesterBalanceRecord.FloatingUsed)},
    {type:"Jury Duty", balance:Value(_requesterBalanceRecord.JuryDuty)-Value(_requesterBalanceRecord.JuryDutyUsed)},
    {type:"Bereavement", balance:Value(_requesterBalanceRecord.Bereavement)-Value(_requesterBalanceRecord.BereavementUsed)}*/
   )
)

 

5. ManagerSendEmailScreen -> OnVisible

Concurrent(
    Set(_navMenuSelect, "My Leave Balance"),
    ClearCollect(RequesterBalanceCollection, 
    { type: "Vacation", balance: Value(_requesterBalanceRecord.Vacation) - Value(_requesterBalanceRecord.VacationUsed)},
    {type:"Sick Leave", balance:Value(_requesterBalanceRecord.Sick)-Value(_requesterBalanceRecord.SickUsed)}/*,
    {type:"Floating Holiday", balance:Value(_requesterBalanceRecord.Floating)-Value(_requesterBalanceRecord.FloatingUsed)},
    {type:"Jury Duty", balance:Value(_requesterBalanceRecord.JuryDuty)-Value(_requesterBalanceRecord.JuryDutyUsed)},
    {type:"Bereavement", balance:Value(_requesterBalanceRecord.Bereavement)-Value(_requesterBalanceRecord.BereavementUsed)}*/
   )
)

 

I tested this out so it should work. But let me know if it doesn't. 

 

---
If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

 

Thanks!

Hardit Bhatia

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

 

 

Dear @PowerAddict good day.

 

Many thanks for your inputs, it has solved my issue with the extra types of leave.

I assume that the same procedure, backwards, should be followed in order to add new types of leave.

 

Another Q: On the excel created in the powerapps backbone, with all the information, how can I add Org's rest of employees?
Just by adding their e-mail and balance?

dB4
Helper III
Helper III

@PowerAddict,

 

I have accidentaly deleted the 'Manager' section, meaning that there's only Employee Login, and once a request is submitted, manager only receives the notification e-mail.

 

Ok, so i copied the button and its function from the default template, and im facing 2 issues now.

When i login as a Manager, i'm getting the above error, and the submitted requests are not visible for review.

 

Office365Users.UserPhotoMetadata failed: The method 'UserPhotoMetadata' has an invalid value for parameter 'userId'

 

Glad I could help!

 

1.

Q: I am not sure I understand your 1st question: "Another Q: On the excel created in the powerapps backbone, with all the information, how can I add Org's rest of employees? Just by adding their e-mail and balance?"

A: I don't think there is an excel that stores the data. There are 2 connectors that the app uses - Office365 and Office365Users. 

 

2. 

Q: When i login as a Manager, i'm getting the above error, and the submitted requests are not visible for review.

A: Did you include this in your OnVisible property of LoginScreen?

Set(_selectedApprover, Office365Users.Manager(_myProfile.Id));

 

Let me know if this helps. If not, it might be easier to start again from the template and make the changes I suggested originally to remove the leave types you don't want. 

 

---
If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

 

Thanks!

Hardit Bhatia

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

 

Hello @PowerAddict 

 

Yes, this was already included in the OnVisible field.

 

Regarding the Excel, indeed there is a file with all the App stored information

OneDrive - *****\PowerApps\Templates\LeaveRequest_b37411a99d4

 

Hi There, May i ask how you were able to change the Leave Balance, i am struggling

Hello there mate,

Which leave balance you wanna edit? the naming or the values?

The values can be edited through the Excel in OD.

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 (1,282)