How to re-arrange a string variable in Flow Designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2023 06:55 AM
Dear All,
- I am handling an inbound email via Flow Designer
- I set a variable called "EndDate" in flow designer
- This variable is a string. I use the variable to parse a date which is in the email body
- The parsed variable has this format: DD/MM/YYYY (for example 19/02/2023)
- I need to use this variable to populate a "Date and Time" field in the sc_req_item table
- Unfortunately, the field takes only dates with this format: YYYY-MM-DD (for example 2023-02-19)
- To overcome it, I created a new variable called "EndDateRearranged"
- I wrote this piece of code to re-arrange the date, but it doesn't work.
// Access the input date Flow variable
var enddate = current.enddate;
// Split the input string by "/"
var dateComponents = enddate.split("/");
// Rearrange the components in the desired order
var enddaterearranged = dateComponents[2] + "-" + dateComponents[1] + "-" + dateComponents[0];
// Set the rearranged date value to an output Flow variable
current.enddaterearranged = enddaterearranged;
Just for clarity, this is how the flow looks like.
In the "Action 2" I set the "EndDate" variable and in "Action 3" I set the EndDateRearranged
Attached is the error trace.
Can you please help?
- Labels:
-
flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2023 02:27 AM
Dear All,
I could not figure out how to use the scripts, so I managed to find an alternative solution.
Trigger of the flow is "Inbound Email"
Action1: Parse Email Body Text (action can be downloaded here)
Action2: Set Flow Variables. I created two flow variables and both variables are parsed from the email
- UserName
- EndDateString
Action3: Submit Catalog Item Request. I then used the "Fuction" option to convert the string to a date. See image below.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2023 02:36 AM
Hi @AEterni
If you can change it from the flow using transform functions is a much better solution then using a script in the action.
I was under the impression you needed to do in the action. The script I provided should have worked there, but maybe I'm overlooking something in your usecase.
Glad you were able to solve it!
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.