web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Update the underlying ...
Power Apps
Unanswered

Update the underlying tables based using Patch()

(0) ShareShare
ReportReport
Posted on by 63

Hello ,

I have a scenario and I am trying to get it passed, hoping if somebody can assist here please.
I have 2 tables :
Holiday_Per_Shift :

Calendar_DateNightorDayShiftBusiness_UnitSlot_IDSlots
31/05/2023DBPhase 615

 

Employee_Details:

Employee_NameEmployee_Slot_ID(auto generated)Slot_ID
Test11000-00011
test21000-00021

Employee_Details column Slot_ID is a lookup column based on Holiday_Per_Shift table

 

Using Power Apps, dynamic control , I am able to select a date in Calendar and show the information in gallery.
Now, I have added a button in the App screen and I want it to patch information in these 2 tables according if slots available >0

alexa_028_0-1688998842486.png

Scenario 1:Update  Holiday_Per_Shift  and identify slot_id based on Calendar_Date(comes from calendar) ,
NightorDay,Shift,Business_Unit (comes from dropdown) and reduce slot by 1
Expected data in table :

Calendar_DateNightorDayShiftBusiness_UnitSlot_IDSlots
31/05/2023DBPhase 614

 

Scenario 2 :Add new record to Employee_Details table like :

Employee_NameEmployee_Slot_ID(auto generated)Slot_ID
ABC1000-00011
XYZ1000-00021
username() from power appsAuto generated value1 (comes based on fields selection)


Can someone please help me how I can achieve this?

Categories:
  • alexa_028 Profile Picture
    63 on at

    I could get Scenario 1 working using below patch function :

    Patch(

        Holidays_Per_Shift,

        First(

            Filter(

                Holidays_Per_Shift,

                DateValue(Text(Calendar_Date)) = _dateSelected,

                Shift = Dropdown_Shift.Selected.Value,

                Business_Unit = Dropdown_BU.Selected.Value,

                NightorDay = Dropdown_DayorNight.Selected.Value

            )

        ),

        {

            Slots: First(

                Filter(

                    Holidays_Per_Shift,

                    DateValue(Text(Calendar_Date)) = _dateSelected,

                    Shift = Dropdown_Shift.Selected.Value,

                    Business_Unit = Dropdown_BU.Selected.Value,

                    NightorDay = Dropdown_DayorNight.Selected.Value

                )

            ).Slots - 1

        }

    );

    I couldn't get Scenario 2 working :
    Patch(
    Employee_Details,
    Defaults(Employee_Details),
    {
    Slot_ID: First(
    Filter(
    Holidays_Per_Shift,
    DateValue(Text(Calendar_Date)) = _dateSelected,
    Shift = Dropdown_Shift.Selected.Value,
    Business_Unit = Dropdown_BU.Selected.Value,
    NightorDay = Dropdown_DayorNight.Selected.Value
    )
    ),
    Employee_Name: "SSS",
    'Leave Status': "Requested"
    }
    )

    Scenario 2 formula is having no errors in formula but it is not adding the rows to the database as expected
    Please help me

    @WarrenBelz @Amik  @developerAJ @timl 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 312

#3
Mohsin Ali Profile Picture

Mohsin Ali 252

Last 30 days Overall leaderboard