cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Shap1
Helper I
Helper I

Time/Date field expression not working

Hello and thanks in advance.

 

I'm setting up a flow that sends an email. In that email, I need to format the time better than what it comes out today as:

Shap1_0-1631567163943.png

 

 

I was able to successfully get this to work before but trying the same expression (formatDateTime(triggerOutputs()?['body/hc_startdate'], 'MM/dd/yyyy')) and still getting an error:

 

Shap1_1-1631567253192.png

 

Is my syntax incorrect?

 

1 ACCEPTED SOLUTION

Accepted Solutions
VJR
Solution Sage
Solution Sage

 

Hi @Shap1 

 

You will need to check if the incoming hc_billratechangeeffectivedate is Null or 'No' or if empty is 'True'.

Add conditional statements and turn the flow accordingly.

Do the same for both the dates.

 

At first do a simple compose action for empty(triggerOutputs()?['body/hc_billratechangeeffectivedate'])

See what the output is when the input is 'No'.

Maybe it is False. In that case compare it with using 'bool'  (shown in below links).

 

Using expressions may become complex, so check out the options in the below links whether you want to use Expressions or If Conditional action.

https://sharepoint.stackexchange.com/questions/293079/power-automate-flow-check-if-date-is-not-empty...

 

https://www.dynamics365crm.org/post/check-if-a-field-date-is-blank-in-microsoft-automate






-------------------------------------------
Help fellow beings find relevant posts.
Upvote to a supporting response.
Mark as solution to an answer.

View solution in original post

12 REPLIES 12
annajhaveri
Super User
Super User

@Shap1  can you check if the value of triggerOutputs()?['body/hc_startdate'] is no value or blank?  from error it looks like there is no value for hc_startdate

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.

Hi @Ann- Thanks for your reply.

 

I put in the existing normal field and it populates. I'm just trying to convert that to a better date field using an expression. It looks like my expression is not working even though hc_startdate by itself works.

 

Shap1_0-1631625801660.png

 

@Shap1  can you add compose action with this expression triggerOutputs()?['body/hc_startdate'] just to see if it has value or not

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.
VJR
Solution Sage
Solution Sage

Hello @Shap1 

 

Could you please share your formatDateTime expression.

And as requested by Anna check out the Compose action.

 

@VJR @annajhaveri 

Thanks guys. Here's is my compose:

 

Shap1_0-1631719155243.png

 

 

Also, this is my expression: 

formatDateTime(triggerOutputs()?['body/hc_startdate'], 'MM/dd/yyyy')

 

nc1
Frequent Visitor

.

Thanks @nc1.

 

I tried as you suggested: replace(formatDateTime(triggerOutputs()?['body/hc_startdate'],'MM-dd-yyyy'),'-','/')

 

This did not work and came back as the following:

"The template language function 'formatDateTime' expects its first parameter to be of type string. The provided value is of type 'Null'."

Shap1_0-1631746130184.png

 

VJR
Solution Sage
Solution Sage

Hi @Shap1 

 

It doesn't seem to be right that the Compose statement is not printing the actual value of the hc_startdate.

Can you double check why? Is there a value in it? Have you selected it correctly from the Dynamic content.

If that is blank then the error is right about the Null value.

 

 

 

 

nc1
Frequent Visitor

It is something with your current date/time variable. I would cast it as a string to be sure it's the correct format and then ensure that you are selecting the correct dynamic content.

 

I misread prior to my first comment oops.

nc

 

Edit:

https://powerusers.microsoft.com/t5/Building-Flows/Flow-failing-due-to-Null-value/td-p/55527

take a peek at this solution, it may be of help.

@Shap1  you need to put the expression in the Dynamic content -> Expressions, not as a text in compose action. Can you please try putting expression via Dynamic content -> Expressions? and see the value of compose action in flow run?

Regards,
Anna Jhaveri

If I have answered your question, please mark the post as Solved to help other users to identify the correct answer
If you like my response, please give it a Thumbs Up.
Shap1
Helper I
Helper I

Hi @VJR, @annajhaveri@nc1@abm 

 

This expression worked when the date fields are populated:

formatDateTime(triggerOutputs()?['body/hc_billratechangeeffectivedate'], 'MM-dd-yyyy')
 
(from form)
Shap1_0-1631895782961.png

 

(from email)

Shap1_1-1631895811869.png

 

HOWEVER,

it does not work and I get an ERROR if the date fields are set to no and do not need to be populated:

Shap1_2-1631895860864.png

Error:

Shap1_3-1631895887467.png

 

 

How can I do it incase it does happen where they do not need to enter in any dates?

VJR
Solution Sage
Solution Sage

 

Hi @Shap1 

 

You will need to check if the incoming hc_billratechangeeffectivedate is Null or 'No' or if empty is 'True'.

Add conditional statements and turn the flow accordingly.

Do the same for both the dates.

 

At first do a simple compose action for empty(triggerOutputs()?['body/hc_billratechangeeffectivedate'])

See what the output is when the input is 'No'.

Maybe it is False. In that case compare it with using 'bool'  (shown in below links).

 

Using expressions may become complex, so check out the options in the below links whether you want to use Expressions or If Conditional action.

https://sharepoint.stackexchange.com/questions/293079/power-automate-flow-check-if-date-is-not-empty...

 

https://www.dynamics365crm.org/post/check-if-a-field-date-is-blank-in-microsoft-automate






-------------------------------------------
Help fellow beings find relevant posts.
Upvote to a supporting response.
Mark as solution to an answer.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,896)