Convert Date: Need code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2024 09:46 PM - edited 09-12-2024 09:51 PM
Hello all,
I need to convert today’s date to Julian date.
for ex: 13 sep 2024, in julian date it would be 24257.
then i need to append 0001 as suffix to this julian number.
final output = 242570001.
is it possible to run a loop and increment this number by 1 based on a count value provided in one of the catalog variables.
i am creating a flow. In the flow input would be the count variable from cat item. Then the script logic will calculate the numbers above in an array and then store them in an output variable on cat item.
please advise
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2024 07:02 AM
Hi @dvelloriy
I tested the below in background it should work :-
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2024 09:11 AM - edited 09-13-2024 09:12 AM
Hi @Ravi Gaurav , I was able to write the action and insert in my flow, its looking good.
Can we modify this script to include a validation step?
I need to check if these generated numbers (asset tags) are present in alm_hardware table or not.
If no, then we should continue with our logic, otherwise we need to skip the ones present and generate unique asset tags only. Please advise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2024 07:48 AM
Hi Ravi, This is awesome and works great.
Do you know how i can modify this logic now to include Count (input variable on cat item) and the array result should be displayed in output variable (on cat item).
i am planning to write a flow however if there is other easy way to do this, let me know plz.
Appreciate your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2024 08:00 AM
create custom action and pass your variable data as input into it and use script step..assign output