You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Hi!
I need some help here. I'm trying to create a scripted field to show which work shift it was created.
To do that, I need to get the hour of the field "Created"
Could anybody help me to develop the code?
I checked this post and saw how to get the full created date. But all I need is the hour.
If an issue is created at 05:22AM, it should be "Shift1";
If an issue is created at 10:01AM, it is "Administrative Shift"
Hi Yuri,
Thank you for your question.
I can confirm that the best way to achieve your requirement would be to get the value from the created field as you have done and to save this value into a date variable inside of your script.
I can confirm that you would then be able to write some logic inside of your code to extract the hour from the date variable and the example located here shows an example of how to extract the hour from the current date.
Also I can confirm we have a code sample located here which can be run on the Script Console and shows how to get the hour an issue was created from the created field.
Once you have got the hour that the issue was created in your script then you could write some if statements to check if the hour matches a specific hour and if it does add the code to set the field value to the value you require inside the If block.
These examples will be a good reference guide to help show you can extract the current hour out of the created date and to help create the script that you require.
I hope this information helps.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.