- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2023 11:37 AM
Hi All,
Can someone please help me with the catalog client script?
I have two field
1) select_the_type_of_access_required
2) u_description
I need an on change catalog item script
when I select the "type of access" the description should auto fill itself.
Custom table name " u_Azure_role
I have something in place but it wont work 😞
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2023 11:52 AM
Hello @Thomas98 ,
Is select_the_type_of_access_requireds a reference field?
If so, replace
g_form.setValue('description',u_azure_roles.u_description);
with
g_form.setValue('description',user.u_description);
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2023 10:53 PM
Hello @Thomas98
You have to use Script Include Call using client script-
Please open the above link and complete your requirement.
Please mark correct answer and helpful for others if it helps you
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2023 06:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2023 10:53 PM
Hello @Thomas98
You have to use Script Include Call using client script-
Please open the above link and complete your requirement.
Please mark correct answer and helpful for others if it helps you
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2023 11:31 PM
Hello @Thomas98 ,
For lookup select box, you have to use GlideAjax to call the script include and get the value.
You can create catalog client script using the below code:-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('getLookupDescription');
ga.addParam('sysparm_name', 'getDescription');
ga.addParam('sysparm_number', newValue); //newValue will look up field for
ga.getXML(callback);
function callback(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('description', answer);
}
}
Also, create script include with name 'getLookupDescription' and check the client callable check box.
and write the below script and according to the comment of line 6,7 & 10 replace the required data:-
var getLookupDescription = Class.create();
getLookupDescription.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getDescription: function() {
var num = this.getParameter('sysparm_number');
var gr = new GlideRecord("incident"); //replace the table name with the table that you selected in lookup variable
gr.addQuery("number", num); // replace 'number' with the field backend name that you have selected in lookup variable
gr.query();
if (gr.next()) {
return gr.description.toString(); //replace description with the backend name of the description field of the table that you selected in lookup variable
}
},
type: 'getLookupDescription'
});
for reference:-
If this response clears up your doubt, kindly flag it as both helpful and correct.
Thanks,
Alka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2023 06:11 AM
Thank you Alka for taking the time.
I still couldn't get it working 😞 could you please validate my code:
Script Include:
Catalog client script:
Azure table fields:
u_role
u_description
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2023 06:30 AM
@Thomas98 , what is the variable name of description where you want to display description from table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2023 06:32 AM - edited 10-18-2023 06:33 AM
@Thomas98 Also, did you make the script include client callable and with the name 'getLookupDescription'? Send me the screenshots.