cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Patch Time Only

How can I patch a SharePoint data/time field with only time when using default date/time data card on a form?

 

I am building an app to create recurring items on list which is then displayed in a calendar view.  I am able to create recurring items with patch, but I can't figure out how to edit the series of items while leaving the date as is.  Just like the classic SharePoint calendar, I am not allowing the user to change the date when editing the series.  I tried to patch just the time, but this sets the date to 1/1/1970.  This is the time section of the formula I am using:

 

ClearCollect(colUpdate, Filter(DataSource, MainID=ThisItem.MainID));
ForAll(
    colUpdate As aPatch, 
    Patch(
        DataSource,    
            LookUp(DataSource, ID=aPatch.ID), 
                {
                'Start Time':
                    TimeValue(
                        Time(
                        StartTime_HourValue.Selected.Value, 
                        StartTime_MinuteValue.Selected.Value,0)), 
            
                'End Time':
                    TimeValue(
                        Time(
                        EndTime_HourValue.Selected.Value, 
                        EndTime_MinuteValue.Selected.Value,0))
}
)
)

 

The collection collects all the items with the same MainID which is created with the new recurring item patch and the ForAll updates all items. 

 

Is there a way to patch just the time while leaving the date alone?   

 

1 ACCEPTED SOLUTION

Accepted Solutions

@FLMike Thank you for the alternate way to do the ForAll using ThisRecord.  I prefer that method to what I was doing.  The DateAdd did not work for me.  This is just adding one hour to the time.  However, this section of your formula sparked some new thoughts in my mind.  After a few attempts to make it work with ThisRecord, I got it to do exactly what I need it to do... leave the dates alone and only update the time.  This is my updated formula now for just the start and end time.  

ClearCollect(colUpdate, Filter(DataSource,MainID = ThisItem.MainID);

    ForAll(
        colUpdate,
        Patch(
            DataSource,
            ThisRecord,
            {
                'Start Time': DateTimeValue(
                    DateValue(ThisRecord.'Start Time') & " " & TimeValue(
                        Time(
                            StartTime_HourValue.Selected.Value,
                            StartTime_MinuteValue.Selected.Value,
                            0
                        )
                    )
                ),
                'End Time': DateTimeValue(
                    DateValue(ThisRecord.'End Time') & " " & TimeValue(
                        Time(
                            EndTime_HourValue.Selected.Value,
                            EndTime_MinuteValue.Selected.Value,
                            0
                        )
                    )
                )
}
)
)

 

View solution in original post

7 REPLIES 7
FLMike
Multi Super User
Multi Super User

Hi @Alex-W 

 

Maybe I am misunderstanding, but are you not able to grab the current Value (including Date), create your own New Date/Time Value (with the Date of the current value + your New Time) and patch with that?


If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

Cheers

Thank You
Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
https://gernaeysoftware.com
LinkedIn: https://www.linkedin.com/in/michaelgernaey

@FLMike I can patch the date and time just fine.  For this part of my project, I want to give the user the ability to update multiple items except for the date of each item.  They can only update the time.  So, for example, this a list of recurring items:

 

TitleStart TimeEnd TimeMainID
Meeting 17/1/2024 09007/1/2024 1000AbcXyz-1234
Meeting 17/2/2024 09007/2/2024 1000AbcXyz-1234
Meeting 17/3/2024 09007/3/2024 1000AbcXyz-1234
Meeting 17/4/2024 09007/4/2024 1000AbcXyz-1234

 

After creating this set of recurring events, the user edits the series and changes the start time to 1100 and end time to 1200.  If I allow the patch to update the date and time, it will update all dates to the same date and that will be a problem.  So, I need the patch to only change the time and leave the dates alone.

Hi @Alex-W 

 

I really don't understand so bear with me.

 

I am looking at your screen image (thank you), and if I wanted to just change row 1

I would say the below and it wouldn't update them all so not sure why you think it will

 

Patch(MyTable, LookUp(MyTable, StartDateTime = 7/1/2024 0900 And Meeting Title = Whatever And MainID = whatever),

    {

       Start TIme: grab the current date append a new time and done. 

    }

);

 

Also, you shouldn't build a data model that doesn't have a row identifier in it or somewhere to tell what makes a record unique.

 

But based on what you showed me, I just showed you how to update it.


If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

Cheers

Thank You
Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
https://gernaeysoftware.com
LinkedIn: https://www.linkedin.com/in/michaelgernaey

@FLMike I am not changing just one row.  By editing the series, all four rows are updated with the patch.  The row identifier here is the MainID column.  Each recurring series has a unique MainID and the collection collects all the items with the same MainID so that the series can be updated with one patch.

 

Try this to get a better understanding of what I trying to do.  Go to the classic calendar on SharePoint and create a recurring event.  It does not matter if it is daily, weekly, or monthly.  Just make sure the event is on the calendar multiple times.  Now, edit the series.  You will see that you have the option to change only the time.  This is what I am trying to replicate in my app.... edit the series of recurring events, allow the user to change the time only and leave the date as is.

 

 

@Alex-W 

 

I get better now that you want to update them all, but respectfully you do not have a ROW identifier. Identifiers are unique, yours is not.  You have a Batch identifier. A Row identifier would make this easier (as it would work in tandem with your batch  id)

 

And FYI, when you do what you asked in the Calendar, it's doing what I am explaining in the back end.

 

As a couple of Examples I made this list

FLMike_0-1719939283244.png

 

 

Example: Update each Start/End Time Only - which is what you are wanting to do

// I am adding this instead of doing Aliasing for this sample
ClearCollect(_tmpCollection, Filter(DateTimeSample, Title = "A"));

ForAll(_tmpCollection,
    Patch(DateTimeSample, ThisRecord,
        {
            Start: DateAdd(ThisRecord.Start, 1, TimeUnit.Hours),
            End: DateAdd(ThisRecord.End, 1, TimeUnit.Hours)
        }
    );
);

 

 

Now after I run the button code

FLMike_1-1719940730620.png

 

the Dates are the same the times are updated


If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

Cheers

Thank You
Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
https://gernaeysoftware.com
LinkedIn: https://www.linkedin.com/in/michaelgernaey

 

@FLMike Thank you for the alternate way to do the ForAll using ThisRecord.  I prefer that method to what I was doing.  The DateAdd did not work for me.  This is just adding one hour to the time.  However, this section of your formula sparked some new thoughts in my mind.  After a few attempts to make it work with ThisRecord, I got it to do exactly what I need it to do... leave the dates alone and only update the time.  This is my updated formula now for just the start and end time.  

ClearCollect(colUpdate, Filter(DataSource,MainID = ThisItem.MainID);

    ForAll(
        colUpdate,
        Patch(
            DataSource,
            ThisRecord,
            {
                'Start Time': DateTimeValue(
                    DateValue(ThisRecord.'Start Time') & " " & TimeValue(
                        Time(
                            StartTime_HourValue.Selected.Value,
                            StartTime_MinuteValue.Selected.Value,
                            0
                        )
                    )
                ),
                'End Time': DateTimeValue(
                    DateValue(ThisRecord.'End Time') & " " & TimeValue(
                        Time(
                            EndTime_HourValue.Selected.Value,
                            EndTime_MinuteValue.Selected.Value,
                            0
                        )
                    )
                )
}
)
)

 

hi @Alex-W 

 

So essentially you are doing what I Suggested first,  which was simply append the new time to the end.

 

It works of course. I would have to see your code because DateAdd isn't something that just works for one person and not another.

 

Either way you did it how i suggested originally so /shrug said no to that  so i wasted time giving you a faster solution, which you also didnt use or give credit for. hmm

 

 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,561)