Hi Experts,
I have date picker for date and for time I have used dropdowns. Now I need to send those data into collect and patch function
Here my code-
What I was thinking is taking that date into label named dateandtime as shown in above image and sending that label into patch and collect function.
But how to pass it-
Can I use just dateandtime? It is not giving me error in patch function but in Collect it is throwing error.
How can I date with time without error?
Any help is appreciated!
@Anonymous I found this forum post that will hopefully be of use to you. It looks like there is a different kind of syntax with the Two Option data type. Here is the way it was done in the solution post:
// Their example:
If(Toggle1.Value=true, 'IsOverdue (TaskLists)'.Yes, 'IsOverdue (TaskLists)'.No)
// In general terms:
If(Toggle1.Value=true, 'FieldName (EntityName)'.TrueValue, 'FieldName (EntityName)'.FalseValue)
Again, being a SQL guy, this is a bit out of my expertise but, hopefully, this example and that forum post get you where you need to be!
Hi @wyotim ,
Thanks for the response.
I have tried that already not working. Even I tried using variable. Any other thing which I can try?
@Anonymous Unfortunately, I don't have much experience at all with CDS; the company I work for primarily uses Azure SQL.
I was able to find a blog post that referred to the Two Option data type. While it seems to work similar to a boolean field, it looks like it needs the actual item value used in CDS. Here is a link to that article. The relevant info I was looking at is under the heading "Writing Changes", near the bottom of that section. This article is from 2018 and about an experimental feature that doesn't seem to exist now, so I am assuming it was rolled out.
So instead of 'Toggle1.Value', maybe having a statement like:
If(
Toggle1.Value = true,
TrueItem,
FalseItem
)
where TrueItem and FalseItem are the actual values for the Two Option data.
If that doesn't work, we may need to track down someone with more CDS experience than me to help with that part. Let me know how it goes and we'll proceed from there!
HI @wyotim ,
Sure will try. Also, I have toggle buttons here in powerapps which has "two options " datatypes in CDS entity. How can I use that in collect. I have used Toggle1.Value but it throws error saying invalid argument in collect. How can i do that?
@Anonymous Rather than making a new label that holds that formula, you should actually put the formula in your Patch and Collect statements where the reference for that label is. So, where you currently have 'Journeydateandtime' in those formulas, put:
DateTimeValue(Substitute(Dateandtime.Text, "Time", ""))})
I hope that makes sense. Basically, you don't need to have another label; you can reference the one you already have and let the formula above take care of the formatting. Let me know if that does what you need or not!
Hi @wyotim ,
Thanks for the response!
My data source needs it to be date an time value so it won't text. I have tried second approach- created one label as shown below
but it is not working in collect function
Am I missing anything?
Hey @Anonymous, I think one issue might be that you seem to be missing the ".Text" portion on the Dateandtime reference. Essentially, it is referencing the control itself and not the text value of the control. So it should probably be:
... journeystartdateandtime: Dateandtime.Text});
...
This is assuming that your data source will take this value as text and doesn't need it to be an actual datetime value. There will likely be an error saying it was expecting a datetime value but received a text value if that is the case. If it needs to be a datetime value, you would probably need to remove the "Time" text from the front and format the resulting text as datetime. Here is one way you could do that:
... journeystartdateandtime: DateTimeValue(Substitute(Label1.Text, "Time", ""))});
...
Basically, the substitute function replaces the text "Time" with nothing (""), and the DateTimeValue function formats the rest as a datetime value (unsurprisingly).
Hopefully, that helps! Let me know if it does or doesn't sort things out; I'm happy to follow up if needed!