Hello,
I'm having major issues with getting my flow to support blank fields and date fields from excel.
I have an excel document that is displaying date fields but in some cases they're optional, meaning the field could be blank. I need to send these dates in an email and either show the date if its there, or leave it blank/display 'N/A' if there isn't a date.
I've searched and searched for this answer, have tried various expressions including addDays, formatdatetime, tried adding in compose functions etc and none of them are supporting both blank and not blank date fields.
This is the expression i'm using so far which works perfectly for when the date is blank:
if(empty(outputs('Get_a_row_3')?['body/What is the expiry date of RTW?']), null, formatDateTime(outputs('Get_a_row_3')?['body/What is the expiry date of RTW?'],'dd/MM/yyyy'))
but as soon as i do a test where there's a date in place, it doesn't just format the date thats present... I get the following error instead:
Unable to process template language expressions in action 'NHS_Pass_Email' inputs at line '0' and column '0': 'In function 'formatDateTime', the value provided for date time string '45074' was not valid. The datetime string must match ISO 8601 format.'.
I've also tested by switching the date and time format in my 'get a row 3' block to ISO 8601 and that doesn't work when the date is blank, but the error when the date isn't blank tells me i need to change something here, but then it wont work for both scenarios. Literally pulling my hair out!
I need an expression or a general answer to tell me how to set this up so that it will include a date in the email if present and still work if the date field is blank. Any help is greatly appreciated!
Thanks