cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bbsin
Post Prodigy
Post Prodigy

another scenario - patch one 1 slot taken and also able to return back and user email - how to??

Hi

 

I have another issue 

I have two list - admin list to input the total of slot available and track

user list when user book or unbook the slot.

 

A is an input box, - to default as 1

how to patch slot take that is 1 to admin list and B will should the reminder out of the total 

 

when the user click unbook, this record should delete and return the 1 slot back to the total of the admin list and remove the slot taken; user record should be removed in the user list too?

Do I need to set Variable somewhere? 

Patch(Admin,  {NumberofSlotTaken: NumberofSlotTaken - inputtextA.text});

Patch('user, Defaults('user'), {Title: Title.text, NumberofSlotTaken: ...});

 

Also how to patch by the reservedby - user email into the list?  It's Person/Group field in SP list.  

 

Thanks

 

1.PNG

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @bbsin 

1. To get the Department, you need to use the Office365Users connector. Then try formula like this:

(must add Office365Users connector first)

ReservedBy:
{'@odata.type':  "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: "i:0#.f|membership|" & User().Email,
DisplayName: User().FullName,
Email: User().Email,
Department: Office365Users. UserProfile (User().Email).Department,
JobTitle: "",
Picture: ""
}

 

2. Try this formula to update the Number inside your patch function:

{NumberofSlotTaken:LookUp(AdminEventInfo,Title=ThisItem.Title). NumberofSlotTaken-Value(InputSlot.Text)}

 

3. Seems that you are using formula like below to show results like “4 of 5” or “5 of 5 ”:

Text(ThisItem. NumberofSlotTaken ) & " of " & Text(ThisItem. TotalofSlots )

 so for unbook button, you can directly update this NumberofSlotTaken to make it add 1:

{NumberofSlotTaken:LookUp(AdminEventInfo,Title=ThisItem.Title). NumberofSlotTaken+1}

 

4. Set OnVisible property of your screen to:

Set(varDisplay,1)

valbaimsft_0-1624952388817.png

 

For unbook button, set its Visible property to:

If(varDisplay=1,false,true)

And set OnSelect property of unbook to:

Set(varDisplay,1)

 

For book button, set its Visible property to:

If(varDisplay=1,true ,false)

And set OnSelect property of book to:

Set(varDisplay,0)

Best regards,

Allen

View solution in original post

17 REPLIES 17
v-albai-msft
Community Support
Community Support

Hi @bbsin 

Are you doing this inside a gallery that is connected to the Admin list?

Is your B a Label? What is the formula for B?

 

Assume that you are editing inside a gallery, so:

For Patch button, do you want to edit the slot value for the selected item in Admin list and also create a new item in user list? If yes, you can try this formula:

 

Patch(Admin, Lookup(Admin, Title=ThisItem.Title), {NumberofSlotTaken: NumberofSlotTaken - inputtextA.text});

Patch('user list', Defaults('user list'), {Title: ThisItem.Title,ReservedBy:{'@odata.type':  "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: "i:0#.f|membership|" & User().Email,
DisplayName: User().FullName,
Email: User().Email},
NumberofSlotTaken: ...});

 

Note: to add current user into the ReservedBy Person column, you can use formula like below inside Patch function:

ReservedBy:
{'@odata.type':  "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: "i:0#.f|membership|" & User().Email,
DisplayName: User().FullName,
Email: User().Email
}

For Unbook button, do you want to edit the slot value for the selected item in Admin list and also removed the corresponding item in user list? If yes, try this formula:

 

Patch(Admin, Lookup(Admin, Title=ThisItem.Title), {NumberofSlotTaken: NumberofSlotTaken+1 });
RemoveIf(‘user list’,Title=ThisItem.Title)

 

Best regards,

Allen

bbsin
Post Prodigy
Post Prodigy

Hi Allen,

 

Thanks Let me try to input your suggestion.

 

B formula is ThisItem.TotalofSlots - ThisItem.NumberofSlotTaken  -- SP list is number.. should I change this too??  Thanks

 

I must hv done something wrong.. 

 

Do I need to set a variable somewhere.. if not how to patch the date and and time too?  Thx 

 

1.PNG

 

Hi @bbsin ,

What is your issue now?

Which date and time do you want to patch? If you want to patch the time like "12:00 to 13:00", just add a new Text column in your SP list, for example called "TimeText", then in the Patch function, use formula like this:

...

{

...

TimeText: Text(ThisItem.DateBooked,ShortTime24) & "to" & Text(ThisItem.DateClosed,ShortTime24),

...

}

...

Best regards,

Allen

@v-albai-msft 

 

the date time column is set in SP as Date - Field DateTime for Datebooked and DateClosed

Do I need to break into date for day and any column for Time?

 

if not how I can just patch as Datebooked: Datebook.selected.DateTime??  NOt sure how to patch it.

Hi @bbsin ,

Do you mean this DateTime column is a Date column including time in your list? And do you want to patch a date with time into your list? 

What is your Datebooked? Is this a date column in your SharePoint list or a DatePicker control in your app? 

Best regards,

Allen

Hi @v-albai-msft 

 

 

Yes both are datecolumn SP list

bbsin_0-1624426801033.png

 

There's no date pick in PowerApps.  

it's just a display 

Text(ThisItem.DateBooked,ShortTime24) & " to " & Text(ThisItem.DateClosed,ShortTime24)

Regards

Hi @v-albai-msft 

 

what did I patch wrong?

 

The book is always to be 1 slot taken from total  

and unbook to return the 1 slot.. 

 

if I put  {NumberofSlotTaken: NumberofSlotTaken - InputSlot.Text});  also cannot work

bbsin_2-1624526486519.png

bbsin_3-1624526565208.png

 

 

 

I want to remove the arrow but  I hv set varBook, this item.  is it ok to remove it?  I don't  need the arrow.  thanks

Hi Allen @v-albai-msft 

 

Can you kindly help. I cannot patch it.. 

bbsin_0-1624865624037.png

 

 

If I use this to patch is ok (I saw fr Shane video) but I cannot patch the user email; name and department with the syntax you provide. can you advise thanks

 

 

 

bbsin_1-1624866261847.png

 

and the unblock button too thanks

 

my gallery infront is using 

bbsin_2-1624866414635.png

 and it works.. does it link to patch also??  this syntax I try to input the same it cannot work.  Please help..  Thank you

 

Hi @bbsin ,

Due to my carelessness, I missed three property in my previous code, so try this(missing Department, JobTitle and Picture property):

ReservedBy:
{'@odata.type':  "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: "i:0#.f|membership|" & User().Email,
DisplayName: User().FullName,
Email: User().Email,
Department: "",
JobTitle: "",
Picture: ""
}

Don't hesitate to let me know if you still have trouble about this question.

Best regards,

Allen

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,734)