How do we set the category and sub category based on CI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2023 10:31 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2023 11:36 AM
Hi @Atik ,
The logs reflects that "g_form.getElement()" unable to resolve at portal side as it's deprecated.
You can add alert() in the below code part and check if control-clow is going inside that.
var category = Array.from(g_form.getElement('category')).map(function(item) {
return item.text;
});
-Thanks,
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2023 01:37 AM
Hi @AshishKM,
I tried to add alert but nothing is happening, could you please help with any other suggestion.
Thanks,
Atik Bagwan.