Hello all. I'm parsing JSON from an online form, and I need to change the date formats for any date fields. That expression works fine (I initialize a variable with the raw data first, then initialize a "fixed" variable underneath that uses FormatDateTime to convert the format). What I did NOT test for were the two optional date fields, which are now returning a "null" value in JSON if not filled out, and it breaks my flow because I get a string error about the data not being in ISO date format (well, there's no data, so duh).
I've tried using the following expression in the Initialize Variable step, and it keeps telling me the expression is invalid:
if(empty(triggerOutputs()?['body/DOM']), 'null', (formatDateTime(variables('Raw_DOM')), 'dd/MM/yyyy'))
Funny thing is, if I remove the bracket in front of formatDateTime and at the end of yyyy, then it allows me to keep the expression, but it breaks when I run the flow because it is thinking it has four elements in the expression instead of three. But when I try to correct it with brackets as above, it won't even let me save the expression because PA says "expression invalid."
Anyone have any solutions for this? Thanks.
Solved! Go to Solution.
Hello @ArchieGoodwin ,
you've got one extra bracket that closes the formatDateTime(...) expression. FormatDateTime(...) needs 2 parameters, the date and the format, but in your expression you close it before you define the format. It should be:
if(empty(triggerOutputs()?['body/DOM']), 'null', formatDateTime(variables('Raw_DOM'), 'dd/MM/yyyy'))
Hello @ArchieGoodwin ,
you've got one extra bracket that closes the formatDateTime(...) expression. FormatDateTime(...) needs 2 parameters, the date and the format, but in your expression you close it before you define the format. It should be:
if(empty(triggerOutputs()?['body/DOM']), 'null', formatDateTime(variables('Raw_DOM'), 'dd/MM/yyyy'))
Thanks, Tom! Clearly, I was not fully functional when I was reviewing that expression!
Cheers!
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Did you know that you could restore a deleted flow? Check out this helpful article.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
32 | |
32 | |
25 | |
24 | |
21 |
User | Count |
---|---|
64 | |
56 | |
44 | |
37 | |
29 |