How to auto populate date based on choice field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2023 12:09 AM
Scenario is to populate date out based on a choice field and the date out has to get incremented based on choice i select in choice field and the date in value is current date. How to populate date out when i select any choice on a choice field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2024 02:24 AM
use this on line 16,17,18
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2023 12:52 AM
Hi @charan_1 ,
Based on your description I Assume you are trying to increment the Current Date with the selected choice value it might be Date in the numbers.
I can suggest you below steps to perform:
1] Write onChange client script for the choice field you are changing/selecting to increment the number of days to current date
2] Create script include and call from onChange script above to perform server side action
3] In script include you can pass the selected choice value as a parameter and return calculated date
4] You can used GlideDate API to add the selected number of days to current date. Below code might be helpful:
5] You can set the calculated value returned from script include to the current date field
g_form.setValue('curr_date_field',<value returned from Script include>);
Provided below URLs for GlideDate and Script Include for you reference
https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server/c_APIRef
If I am able to help you with your question, Please click the Thumb Icon and mark as Correct.
Regards,
Pushkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2023 01:06 AM
you can achieve this with only client script OR with client script + GlideAjax
can you share what script did you try so far and what didn't work?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader