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

Bert_c1
Kilo Patron

What is the 'UI type' value on the client script? One choice is "All' another choice is 'Mobile / Service Portal'.

YaswanthKurre
Giga Guru

HI @ItayB ,

 

Make sure the UI Type is "All" in your client script.

 

Mark this as helpful and correct, if this solves your issue.

 

Thanks,

Yaswanth

It amazes me why members post the same solution as was previously posted. Client Scripts do work in the Service Portal, it the type is not "Desktop".

Hi @WillieW ,

 

If you check the response, it was a question asked and suggested 2 of 3 options available, But my answer is having type as All- as this will work in both Classic and Portal views.

 

Client Scripts do work in the Service Portal, it the type is not "Desktop"- yes, they do will they work in Classic view as well, if you not explicitly selected All?