- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 01:41 AM
Hi Team,
I have a Requirement that there are field on 'cmdb_ci' table category and subcategory and we have fields on INC form configuration item, category and subcategory.
If user selects configuration item then on INC form category and subcategory should got auto populated.
I am using below code and it is working fine for INC form
function onChange(control, oldValue, newValue, isLoading, isTemplate) { if (isLoading) { return; } var category = Array.from(g_form.getElement('category')).map(function(item) { return item.text; }); var ci = g_form.getReference('cmdb_ci', setRelatedValue); function setRelatedValue(cmdbCI) { var ciCompany = cmdbCI.company || ''; var ciCategory = cmdbCI.category || ''; var ciSubcategory = cmdbCI.subcategory || ''; g_form.setValue('company', ciCompany); g_form.setReadOnly('company', Boolean(ciCompany)); if (category.includes(ciCategory)) { g_form.setValue('category', ciCategory); setTimeout(function() { var subcategory = Array.from(g_form.getElement('subcategory')).map(function(item) { return item.text; }); if (subcategory.includes(ciSubcategory)) g_form.setValue('subcategory', ciSubcategory); }, 1000); } }
and we have same fields on Record Producer like configuration item, category and subcategory. and we want same thig like If user selects configuration item then on form which is on employee center and (it is record producer and its target table is Incident) category and subcategory should got auto populated
But when I am trying to use the same code then it is not working and when i inspect on browser then i get the below errors...
Please help me on this,
Thanks,
Atik Bagwan.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 01:45 AM
Hi @Atik ,
Did you try to use datalookup rules instead of script ? i belive datalookup rule must help you set the values of both fields based on CI fields.
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 01:45 AM
Hi @Atik ,
Did you try to use datalookup rules instead of script ? i belive datalookup rule must help you set the values of both fields based on CI fields.
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 05:02 AM
@Sohail Khilji , it worked thanks a lot!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 05:05 AM
Hi @Atik
Did you use script or data lookup?
I am curious to know, for data look up, how big is your list or use dynamic?
Bcz I want to propose the same solution but did not write bcz of feasibility and I am happy @Sohail Khilji clear my doubt by putting same thoughts. So I would like to know the answer from you.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************