- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2024 05:21 AM
Hi,
We have created a custom field 'total time' duration field. When incident state is resolved we want to populate that field with business duration field which is already present on incident table. I created business rule and onsbmit client script as well but that field is not auto populating with the value can anyone help me on that?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2024 05:51 AM
share your BR condition and script you are using?
the new custom field is of type duration?
script should be something like this and BR should be Before Update
Ensure your BR triggers fine and the below script will work fine
current.durationField2 = current.durationField1.dateNumericValue();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2024 06:03 AM
Hi @Burhan2 ,
Use below code in your BR, it will work. I have tested it in PDI.
var gr = new GlideRecord('incident');
if (gr.get(current.sys_id)) {
current.u_business_duration = gr.business_duration;
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2024 05:28 AM
Hi @Burhan2 ,
You can achieve it using before update BR.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2024 05:32 AM
I tried exactly same this with my field but its not working when incident gets resolved the business duration field gets filled but my custom field is still empty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2024 05:37 AM
Hi @Burhan2 ,
I guess, the field type is not same for both the fields, can you check the type of field in the dictionary for both "Business Duration" and your custom field?
---------------------------------------------------------------------------------------------------
Please mark my answer as helpful/correct if it resolves your query.
Thanks,
Nilesh Wahule
---------------------------------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-26-2024 05:41 AM
Yes type is 'duration' for both the fields