Maintain item field change when another field is choice

Dario_C
Mega Sage

Hi guys, I have an urgent task to do. I have an item Keep with "type" field with value to point to service_offering, each service_offering has in the endorseable option for different item.

When the user chooses the type (service_offering) I must show the description of the current choice of service_offering under an information box or inside another field (I don't know).

If I try with the catalog script, do I have to make a glide record on service_offering and take the description field? Or is there another simple method to show description on field type? 

 

Thanks in advance ! 

1 ACCEPTED SOLUTION

Dario_C
Mega Sage

To show the description of the service offer each time the user chooses another, i needed to do a Script Include for retrieve the description with glide record  and  then an catalog client script  with an call back function. 

Here the Reference: 

https://www.servicenow.com/community/developer-forum/auto-populate-description-field-based-on-the-va...

 

Thanks everybody for the support. 

View solution in original post

5 REPLIES 5

Samaksh Wani
Giga Sage
Giga Sage

Hello @Dario_C 

 

You can use onChange Client Script.

 

Where on change of field, you can populate the description value.

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

DanielCordick
Mega Patron
Mega Patron

Hi Dario,

for this you want to use an onChange client script 

 

 

function onChangeChoiceField() {
var choiceField = g_form.getValue('choice_field'); // Get the value of the choice field

if (choiceField === 'x') {
g_form.setValue('description', 'Description for choice x');
} else if (choiceField === 'y') {
g_form.setValue('description', 'Description for choice y');
} else if (choiceField === 'z') {
g_form.setValue('description', 'Description for choice z');
} else {
g_form.setValue('description', ''); // Set an empty value if none of the specified choices are selected
}
}

 

Here is just a quick example of an onChnahe client script, if you just want to add an info message you can use 

g_form.showFieldMsg('field_1', 'This is a showFieldMsg message', 'info');

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response helped in any way 

 

Hi @DanielCordick ,

 

Thanks for your answer, this script work also when service_offering  is a Lookup Select Box field ? 

yes it should work