How to Update "Short description" with Selected Choice Label from "On hold reason" in SOW?

ItayB
Tera Contributor

Hi everyone,

I'm trying to implement the following logic in the Service Operations Workspace (SOW) form:

Whenever the field "On hold reason" (a choice field) changes — before the record is saved — I want to copy the label (not the value) of the selected choice into the "Short description" field.

I've already implemented this successfully using a Client Script on the standard form, but it doesn't work in the Configurable Workspace (SOW).

Is there a way to achieve this using Client View Rules, Data Broker, UI Component configurations, or any other recommended approach in SOW?

Any guidance or examples would be greatly appreciated.

Thanks!

1 ACCEPTED SOLUTION

@ItayB 

that method won't work in workspace as it's not supported. see below

AnkurBawiskar_0-1750938777302.png

This is the workaround

Ensure Global Checkbox is checked in onChange client script so that it works in both native + sow

AnkurBawiskar_1-1750939176926.png

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

	// add your choice values and choice labels in json object
    var reasonLabels = {
        '1': 'Awaiting Caller',
        '2': 'Awaiting Evidence',
        '3': 'Awaiting Problem Resolution',
        '4': 'Awaiting Vendor'
    };

    var value = g_form.getValue('hold_reason');
    var label = reasonLabels[value] || value;
    g_form.setValue('short_description', label);

}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

ItayB
Tera Contributor

Hello, the UI Type is already on "ALL" and still the script isnt working on the SOW. 

ItayB
Tera Contributor

Thank you everyone for your help! 
The UI TYPE is already on "ALL" and still its not working in the SOW - Service Operation Workspace. 
There is another thing i can do ?

 

ItayB
Tera Contributor

I will add my Client Script to here:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') return;

   var selectedOption = g_form.getOption('hold_reason', newValue);
   if (selectedOption) {
      g_form.setValue('short_description', selectedOption.label);
   }
}

@ItayB 

that method won't work in workspace as it's not supported. see below

AnkurBawiskar_0-1750938777302.png

This is the workaround

Ensure Global Checkbox is checked in onChange client script so that it works in both native + sow

AnkurBawiskar_1-1750939176926.png

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

	// add your choice values and choice labels in json object
    var reasonLabels = {
        '1': 'Awaiting Caller',
        '2': 'Awaiting Evidence',
        '3': 'Awaiting Problem Resolution',
        '4': 'Awaiting Vendor'
    };

    var value = g_form.getValue('hold_reason');
    var label = reasonLabels[value] || value;
    g_form.setValue('short_description', label);

}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Worked! Thank you!