Flow designer Action script to take Date input and give output as Day and Month from the date

Dee S
Giga Guru

I've a requirement where I'll give input some Date and I want to get Day and Month of that date. Need script help for that

Example:

input: 2022-08-17

Output:

Day: 17

Month: 08

1 ACCEPTED SOLUTION

Mahendra RC
Mega Sage

Hello @Dee S 

You can follow the below steps.

Go to Flow designer click on create new Action.

1. Create action input step:

find_real_file.png

2. click on + icon and slect Script to create a Script action. Create Input Variables for script step to provide the input to the script. Click on Data pill picker to add the value to this variable from Inputs--> Date time variable. (ie. variable from step 1)

find_real_file.png

In script specify the below script:

(function execute(inputs, outputs) {
  var dateGDT = new GlideDate();
  dateGDT.setValue(inputs.date_value + "");
  outputs.month_value = dateGDT.getMonthNoTZ();
  outputs.date_value = dateGDT.getDayOfMonthNoTZ();
})(inputs, outputs);

Create Output vairable for script step as show below:

find_real_file.png

3. Create Outputs as shown below. You need to first create Output variables. Click on Exist Edit mode button. Then assign the value to those variable by clicking on Data pill picker icon and using the variable created as output variables in step 2.

find_real_file.png

find_real_file.png

Click on Save. Then to test the action click on Test button. Provide the date value and then check the values in flow execution:

find_real_file.png

If my answer helped you in any way then please do mark it as helpful. If it answered your question then please mark it correct and helpful. This will help others with similar issue to find the correct answer.

Thanks

View solution in original post

6 REPLIES 6

Hello @Dee S 

Just wanted to check with you, if the above response answered your question. If yes, then please do close this thread/question by marking the appropriate response as correct.

Thanks

OlaN
Giga Sage
Giga Sage

Hi,

There is no need to create scripted actions, you should be able to use the built in transform functions in Flow Designer.

Example below

find_real_file.png