Solved

Trim DateTime from SharePoint and embed in Loop for Each

  • 1 June 2023
  • 9 replies
  • 62 views

Userlevel 1
Badge +7

Hi 

I am trying to trim date/time extracted from SharePoint to date only and embed it in a message after Loop for Each.

The date/time field may be empty.

The message i receive is populating duplicate dates from a line item for blank fields. Is there a way to solve this?

Thank you.

icon

Best answer by Garrett 1 June 2023, 15:14

View original

9 replies

Userlevel 1
Badge +5

Hi @mjliu 

I assume after you Loop through each Item and Format the Date then you want to build a HTML text for each Date ...is that right?

or you can simply add ALL the format dates into one Text variable with each Date separated by semicolon ; so that you then RegEx it after the loop using the “Split” operation .

it would be great to see ( a screenshot ) of the “Create Text String” action what are you trying to compile as a text?

 

Thanks,Majid

Userlevel 1
Badge +7

Hi Majid, pls see below

I was trying to create another column in SharePoint to convert date to text (calculated column) but not able to find this column in Loop for each to build the message. is it not supported at Nintex? I am able to see the column in Query a list action.

Userlevel 1
Badge +5

Hi @mjliu 

Thanks for your reply, 

does the Format Date action return  the Date format as :YYYY-MM-DD as expected? is that what you wanted to return? or it return different text value for the “Project Exp Completion Date” ?

Thanks,Majid

Userlevel 1
Badge +7

Thanks Majid.

 

The format is fine, but i am getting duplicate dates in the return, so i think it is related with loop for each.

 

Also am i not able to extract calculated value field from SP?

Userlevel 1
Badge +7

It seems so…

 

Userlevel 1
Badge +5

Hi @mjliu 

i see...could be that because you might have a nested loop? do you have more than one loop in the design?

please send us a screenshot of the action : “Create Msg for tracking Email” ?

Thanks,Majid

Userlevel 6
Badge +16

Hi @mjliu 

 

The issue is because you only reset the txtExpectedCompletionDate variable once (in the beginning)
When you encounter a blank date value, you should reset the txtExpectedCompletionDate variable otherwise it will contain the value of the previous date.

There 10 rows. Only the first row has a filled date - 1-June 2023. The rest has empty dates.
Because you do not reset the txtExpectedCompletionDate variable, the rest 9 rows (which is empty), will get the date of 1-June 2023

 

The solution. Just replace the Run-IF (highlighted) with a Branch by Condition.

Move the Format Date action into the YES branch.
In the NO branch, set the txtExpectedCompletionDate variable to blank string

 

To create a blank string...

 

Hope that helps

Userlevel 1
Badge +7

Thanks, i do not think Format date to string works in this case (not sure why) but Apply a regular expression would work. All good now.

Userlevel 6
Badge +16

Hi @mjliu 

Great to hear that you manage to find a solution!

The Format date to string requires a Date value. It works great
I usually convert the “Current Date and Time” to into a string for humanizing DateTime output

With the 12-May NAC update, you (or your NAC admin) should be able to set the correct date format.


 

Reply