Choice value is not visible to customer but admin can see
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2024 04:27 AM
Hi,
I have added Business line (choice field )field in the Product model table. and same added in the Sold product table.
I have written a script include to show the Business line values in the catalog form based on account.
Script include
getBusinessLinePortal: function() {
var bl = [];
var account = this.getParameter("sysparm_account");
gs.log("Account " + account);
var dee = new GlideRecord("sn_install_base_sold_product");
dee.addEncodedQuery('account=' + account);
dee.query();
while (dee.next()) {
bl.push(dee.product.u_business_line_product.toString());
}
gs.log("Business Line " + bl);
return bl.join(',');
},
Client script
function onLoad() {
var account = g_form.getValue("csm_account");
var script_include = new GlideAjax('global.getProductPortal');
script_include.addParam('sysparm_name', 'getBusinessLinePortal');
script_include.addParam('sysparm_account', account);
script_include.getXML(showDetails);
function showDetails(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var array = answer.split(',');
alert("Array " + array);
for (var i = 0; i < array.length; i++) {
g_form.addOption('u_business_line', array[i], array[i]);
}
}
}
Business line options are- Med, Max, Data
When I am impersonating with customer whose account is associated with Data and Med it is working fine but for Med customer Business Line is not visible.
Please help.
Thanks,
Sam
- Labels:
-
Customer Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2024 04:49 AM
hi @Samiksha2
It looks like the issue may be related to how the Business Line values are retrieved and added to the form. Here are a few things you can check:
In your getBusinessLinePortal script, the encoded query is used to fetch records based on the account. If account is not correctly matching or there are issues with data consistency, it might not return results for "Med" customers.
Try logging more details to verify if the correct records are being fetched:
var dee = new GlideRecord("sn_install_base_sold_product");
dee.addEncodedQuery('account=' + account);
dee.query();
gs.log('Total records found: ' + dee.getRowCount()); // Log the number of records found
while (dee.next()) {
gs.log('Business Line: ' + dee.product.u_business_line_product); // Log each business line
bl.push(dee.product.u_business_line_product.toString());
}
Ensure that the u_business_line field on the catalog form has the correct choices added. If a value like "Med" doesn't exist as a predefined choice, it might not appear when the option is dynamically added. You can check the predefined choices for this field in the form layout to confirm.
Confirm if the u_business_line field is visible on the catalog form for the impersonated customer. It’s possible that the field may not be set to visible or might be hidden by UI policies or client scripts under specific conditions.
i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 01:16 AM - edited 09-16-2024 01:16 AM
Hi @Samiksha2
What are the log values for Med customer?
Did you check if there are any Query BR's restricting the records?
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 02:22 AM
Hi @Voona Rohila ,
In logs value is not coming. But for other Business Lines values are coming in the logs.
Thanks,
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 02:36 AM - edited 09-16-2024 02:38 AM
Did you check if there are any Query BR's ? This must be restricting the record querying.
also check the ACL's for that script include, as the logs were not coming .
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 02:56 AM
Hi @Voona Rohila ,
There was a query BR. I deactivated it but still value is not populating.
I have added snc_external and itil role in the ACL for the script include.
Thanks,
Sam