- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 09:40 PM
Hi All,
Need help/Suggestion
The query is when I click on the UI action, the condition need to check no product assigned is false, get the display of the parent , based on the parent display value need to populate number from the cmdb_ci_service_business table.
The below code is populating the alert display name but not populating the number.
When I use the same code in back ground script it is working, please let me why it is not working in the UI action client callable.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 09:46 PM
Hi @Madhusagar Pal1 ,
If u have checked the client checkbox on the UI action then GlideRecord won't work as the UI action will behave like a client script. U can call a script include from the UI action using GlideAjax to perform that operation. This is one way.
Else what u can do is uncheck the checkbox for client,this way ur UI action will behave as a server side script n then u can do something like below.
if (current.noProductAssigned === "false") {
var digitalProduct = current.parent.getDisplayValue();
//alert("digital product value in form: " + digitalProduct);
//instead of alert u can use gs.info n try to print the logs
var digiProd = new GlideRecord('cmdb_ci_service_business');
digiProd.addQuery('name', digitalProduct);
digiProd.query();
while (digiProd.next()) {
var digitalProductNum = digiProd.getValue('number');
}
//alert("digital product number is : " + digitalProductNum);
//Use gs.info to print logs as it's a server side script now. Alert can only be used at client side.
}
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 09:46 PM
Hi @Madhusagar Pal1 ,
If u have checked the client checkbox on the UI action then GlideRecord won't work as the UI action will behave like a client script. U can call a script include from the UI action using GlideAjax to perform that operation. This is one way.
Else what u can do is uncheck the checkbox for client,this way ur UI action will behave as a server side script n then u can do something like below.
if (current.noProductAssigned === "false") {
var digitalProduct = current.parent.getDisplayValue();
//alert("digital product value in form: " + digitalProduct);
//instead of alert u can use gs.info n try to print the logs
var digiProd = new GlideRecord('cmdb_ci_service_business');
digiProd.addQuery('name', digitalProduct);
digiProd.query();
while (digiProd.next()) {
var digitalProductNum = digiProd.getValue('number');
}
//alert("digital product number is : " + digitalProductNum);
//Use gs.info to print logs as it's a server side script now. Alert can only be used at client side.
}
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 09:19 PM
Hi Dinesh,
As you recommended, i tried using GlideAjax but still not working, Please check the below code and let me know.
Client Side:
Server Side(script include):
Please suggest me where i did wrong.
Thanks & Regards,
Madhu.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 09:25 PM
Do you get an array of Product IDs as a response from the script include or it a single product ID ? I can see you have made use of a while loop in the script include to iterate over the spm_taxonomy_node table ?
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 09:27 PM
single product group ID