cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
digiservice
Level: Powered On

Blank date to SQL patch "Server Response: A value must be provided for item"

I have a Patch which is creating a new row in a SQL table using a ForAll and a collection. 

I have a date column that needs on occasion to be blank.

ForAll(
    mycollection,
    Patch(
        mysqltable,
        Defaults(mysqltable),
        {
            mydatecolumn: DateTimeValue(Text(mycollectiondatecolumn))
        }
    )
)

 

 

The SQL column/table is set to accept Null values, however when I patch a null value I get this error:

"Server Response: A value must be provided for item"

 

If I patch a date value it works fine, it only errors when the mycollectiondatecolumn is blank.

 

Is this related to the known issue with blank and nulls? Or am I missing something?

1 ACCEPTED SOLUTION

Accepted Solutions
digiservice
Level: Powered On

Re: Blank date to SQL patch "Server Response: A value must be provided for item"

OK I think I have an answer but will keep testing.

I found to get the date to patch if there is a value or to be blank if there isn't one, the following appears to work:

ForAll(
    mycollection,
    Patch(
        mysqltable,
        Defaults(mysqltable),
        {
            mydatecolumn: Coalesce(Blank(), mycollectiondatecolumn)
        }
    )
)

 

View solution in original post

5 REPLIES 5
PavanKumar
Level 8

Re: Blank date to SQL patch "Server Response: A value must be provided for item"

Hi,

 

Once can you try something like this?

 

ForAll(
    mycollection,
    Patch(
        mysqltable,
        Defaults(mysqltable),
        {
            mydatecolumn: If(IsBlank(mycollectiondatecolumn),Blank(), DateTimeValue(Text(mycollectiondatecolumn)))
        }
    )
)

 

 

If this answers your question mark it as verified and give thumbs up.

Regards,

Pavan Kumar Garlapati

digiservice
Level: Powered On

Re: Blank date to SQL patch "Server Response: A value must be provided for item"

Hi @PavanKumar ,

 

I've tried that and get exactly the same response unfortunately 😞

PavanKumar
Level 8

Re: Blank date to SQL patch "Server Response: A value must be provided for item"

Hi, I think this helps you. http://powerappsexamples.com/patch-null-value/ If this answers your question mark it as verified and give thumbs up. Regards, Pavan Kumar Garlapati
digiservice
Level: Powered On

Re: Blank date to SQL patch "Server Response: A value must be provided for item"

Hi @PavanKumar 

Thanks again for the suggestion and your help. It's odd because I have found this does not work:

ForAll(
    mycollection,
    Patch(
        mysqltable,
        Defaults(mysqltable),
        {
            mydatecolumn: If(IsBlank(mycollectiondatecolumn),Blank(), DateTimeValue(Text(mycollectiondatecolumn)))
        }
    )
)

Where as this does work:

ForAll(
    mycollection,
    Patch(
        mysqltable,
        Defaults(mysqltable),
        {
            mydatecolumn: Blank()
        }
    )
)

I don't know why it would see either output any differently when essentially they both output blank.

For my needs the second option isn't viable as I need to be able to populate if if the date field does have a value.

If I was only updating one column I could wrap it in a conditional as suggested within the blog post you recommended but unfortunately I am patching up to 12 date fields across 166 columns in more than one patch so writing conditions for each potential scenario would be exceptionally messy.

 

I'll keep tinkering to see if I can come up with a solution.

digiservice
Level: Powered On

Re: Blank date to SQL patch "Server Response: A value must be provided for item"

OK I think I have an answer but will keep testing.

I found to get the date to patch if there is a value or to be blank if there isn't one, the following appears to work:

ForAll(
    mycollection,
    Patch(
        mysqltable,
        Defaults(mysqltable),
        {
            mydatecolumn: Coalesce(Blank(), mycollectiondatecolumn)
        }
    )
)

 

View solution in original post

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,474)