The client script is not working in service portal but working in try it option in catalog form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 02:18 AM
I created a on change catalog client script such that based on requested for's country and the options he chose in domain ,category and service fields(reference) will make a particular value be set and read only in service desk filed. Please take a look at the below script and help me out. I did select UI type as ALL and cannot change the whole script but can add to the existing one I added my script after the MX country. I would like the answer ASAP ,as I am running out of time:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 02:24 AM
Hi @Ponnada,
You are trying to do synchronous queries in the functions getDomain, getCategory and getService. This is not going to work. You will have do these asynchronous.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 02:53 AM
How do I do asynchronous queries in function getDomain,getCategory and getService? I have never done it before .Could you please help me out.
Best,
Kasthuri
Kasthuri

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 02:57 AM
Hi @Ponnada,
It somewhat the same as the getReference you have used.
Take a look at the API Documentation for an example.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 07:32 AM
Are we talking about something like the below script:
function onChange(control, oldValue, newValue, isLoading) {
if (newValue === '') {
g_form.clearValue('service_desk');
g_form.setReadOnly('service_desk', false);
return;
}
var requested_for = g_form.getReference('requested_for', setFields);
function setFields(requested_for) {
var country = requested_for.country.toString();
g_form.setDisabled('service_desk', false);
g_form.setReadOnly('service_desk', false);
if (country === "UY") {
g_form.getReference('domain', setDomain);
function setDomain(domain) {
var domainValue = domain.name.toString();
g_form.getReference('category', setCategory);
function setCategory(category) {
var categoryValue = category.name.toString();
g_form.getReference('service', setService);
function setService(service) {
var serviceValue = service.name.toString();
if (domainValue === "PRONTO" && categoryValue === "Backoffice IT" &&
(serviceValue === "Data Operations" || serviceValue === "Production")) {
g_form.setValue('service_desk', '75c0151d97279990840c77100153af4d');
g_form.setReadOnly('service_desk', true);
} else if (domainValue === "PRONTO" && categoryValue === "Backoffice IT" && serviceValue === "Technology") {
g_form.setValue('service_desk', '9618e012476f11d0ea4d0bde536d4316');
g_form.setReadOnly('service_desk', true);
} else if (domainValue === "PRONTO" && categoryValue === "Technical Support") {
g_form.setValue('service_desk', '36686492476f11d0ea4d0bde536d4374');
g_form.setReadOnly('service_desk', true);
}
}
}
}
}
}
}