How to use user input variables in a date/time smartvalue when editing datetime picker field

Patricia Francezi
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 25, 2024

I have a manual trigger to request the Schedule date and time to the user and create the request type in the JSM project.

The user needs to select the next weekday (Mon to Thu)

And the hour of the maintenance start, not the minutes 

I need to set both (weekday and time of day user inputs) to the Planned, Start, Planned End, etc to have this scheduling showing on the Change Management Calendar. 

Those are date time picker fields, so its mandatory to have time and minute set up.

The first thing I did was a rule with if else using the strings to set the weekday - but the problem is - I can't do if/else to the time of the day due to the limitations of components in each automation rule. 

image.png

So I have the following  "structure"

image.png

1) The user Input menu, have 2 variables 

- userInputs.weekday

- userInputs.timeofday

2) Then I have a create request type action as follows 

image.png

The smartvalues functions I tried so far no success

{{now.withNextDayOfWeek("{{userInputs.weekday}}").withHour({{userInputs.timeofday}}).withMinute(0).setTimeZone("America/New_York")}}

It does not get the option for DayofWeek 

Options are set as string MON, TUE, WED, THU

So I thought that being string inside " " would work.

I removed this part of the weekday and tried only 

{{now.withNextDayOfWeek("MON").withHour({{userInputs.timeofday}}).withMinute(0).setTimeZone("America/New_York")}}

The timeofday input is Number, so I assume that it would just replace with the number collected.

It didnt work 

Tried also

{{now.withNextDayOfWeek("MON").withHour({{userInputs.timeofday.asNumber}}).withMinute(0).setTimeZone("America/New_York")}}

It didnt work

3) I tried also to create a new variable {{vartime}}

 

image.png

 

{{now.withNextDayOfWeek("MON").withHour({{vartime}}).withMinute(0)}}

It also didnt work

Help???

1 answer

1 accepted

2 votes
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 25, 2024

Hello @Patricia Francezi 

When using a smart value as an input to a function, you don't usually include the curly braces.

I tested this, using Log actions to print the values in the rule execution Audit Log.

{{now.withNextDayOfWeek(userInputs.weekday)}}

That generated the correct date based on the input.

Use the same concept with the hour of day.

{{now.withNextDayOfWeek(userInputs.weekday).withHour(userInputs.timeofday)}}

Patricia Francezi
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 25, 2024

Learned that. Thanks! 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events