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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch a form with date...
Power Apps
Unanswered

Patch a form with datepicker and checkbox

(0) ShareShare
ReportReport
Posted on by 21

Hey All, 

 

I have a form. In the individual datacards I have a Date Picker and a checkbox. If the record(data source 'Renewals', excel sheet) says "MTM" it is supposed to click the checkbox, if it has a date I want it to input the Date Picker, if its blank, remain blank(unless changed). I am having issues linking it together because I am getting the incompatible records: DateTime,Text warning on each of them. 

 

Checkbox:

Default: If(ThisItem.'i-Communicate'="MTM", true, false)

OnSelect: Patch(Renewals,BrowseGallery1.Selected,{'i-Communicate':Checkbox1})

 

DatePicker:

DefaultDate: ThisItem.'i-Communicate'

OnSelect: Patch(Renewals,BrowseGallery1.Selected,{'i-Communicate':DatePicker1.SelectedDate})

 

Here is a screenshot of one of the datacards as well, for reference:

bjensen1_0-1684157461137.png

bjensen1_1-1684157480714.png

 

Is there a solution out there to make it read both? If I try updating it on a test user, it gives me a runtime error for the patch.

 

Thanks,

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,051 Most Valuable Professional on at

    Hi @bjensen1 ,

    What type of field is 'i-Communicate' - it cannot be both a Date and Boolean (yes/no) and you are trying to patch one of each value. If a Boolean

    Checkbox - Default

    ThisItem.'i-Communicate'="MTM"​

    OnSelect

    Patch(
     Renewals,
     {ID: BrowseGallery1.Selected.ID},
     {'i-Communicate': Self.Value}
    )​

    but I am not sure where you want to put your date value.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • bjensen1 Profile Picture
    21 on at

    Hi @WarrenBelz ,

     

    So this is for a contract section and these are for expirations. Either their contract ends on a date, or they are month to month(MTM). i-Communicate is one of the services provided, but I don't think the history behind that is overly necessary. 

     

    My thought process is:

    It reads the excel sheet, and if it has a date, input it in the datepicker, if it says MTM it clicks the checkbox. I am not intentionally trying to do both a boolean and a date in the same box, as in clicking the box and inputting the datepicker at the same time. 1 of each, just in different controls. Not sure if that makes sense. 

     

    Thanks,

  • WarrenBelz Profile Picture
    153,051 Most Valuable Professional on at

    @bjensen1 ,

    OK - I was assuming you were using SharePoint - you did not specify Excel (which is a bad choice unless you do not have access to SharePoint Lists) - so write them both as Text
    Checkbox - Default

    ThisItem.'i-Communicate'="MTM"​ = "Yes"

    OnSelect

    Patch(
     Renewals,
     BrowseGallery1.Selected,
     {'i-Communicate': If(Self.Value, "Yes", "No")}
    )​

    Date Picker - Default

    DateValue(ThisItem.'i-Communicate')
    

    OnSelect

    Patch(
     Renewals,
     BrowseGallery1.Selected,
     {
     'i-Communicate': Text(DatePicker1.SelectedDate, "dd/mm/yyyy")
     }
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • bjensen1 Profile Picture
    21 on at

    @WarrenBelz 

     

    Sorry for the confusion. I am using excel at the moment due to some ideas I have down the line(regarding the sheet updating). 

     

    I gave your more recent formulas a try. Getting a few errors. 

     

    On Checkbox1:

    Name isn't valid.  'ID' isn't recognized.

    Patch function has some invalid arguments.

    Argument does not match expected 'DateTime'. Found 'Text'.

     

    DatePicker1:

    Patch function has some invalid arguments.

    Argument does not match expected 'DateTime'. Found 'Text'.

     

    Also getting an error that 'ID' column does not exist. Am I supposed to be replacing ID with something?

     

    I appreciate your help.

  • WarrenBelz Profile Picture
    153,051 Most Valuable Professional on at

    @bjensen1 ,

    You can drop the ID (still thinking SharePoint and did not change - just make it BrowseGallery1.Selected, (fixed in post) however if that is a date field, you cannot patch the yes/no value to it, so we are back where we started. 

  • Shaheer Ahmad Profile Picture
    2,194 Moderator on at

    Please try Text(ThisItem.'i-Communicate')="MTM"

  • bjensen1 Profile Picture
    21 on at

    @WarrenBelz  this is for both default and onselect of the checkbox.

    bjensen1_0-1684354999704.png

     

  • bjensen1 Profile Picture
    21 on at

    @ShaheerAhmad 

     

    The OnSelect: Patch(
    Renewals,
    BrowseGallery1.Selected,
    {'i-Communicate': "MTM"})

     

    Default:

    Text(ThisItem.'i-Communicate')="MTM"

     

    Seems to get the error that "MTM" cannot be converted to a DateTime.

     

  • Shaheer Ahmad Profile Picture
    2,194 Moderator on at

    Confirm the datatype of the 'i-communicate' column. I think its datatype is Date/Time....

  • Shaheer Ahmad Profile Picture
    2,194 Moderator on at

    First of all in ur gallery add a text label and on its text property please add ThisItem.'i-Communicate' and check what output is shown in the gallery.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard