Need to change UI Action display name with client script

pbo
Mega Expert

Hi, 

I would like to change the name of a specific UI Action based on 

For exemple on incident table, there is Create Problem UI Action ((OOB)

We need to keep this UI Action but change the name to Create Technical Problem when category of Incident is Technical. 

I may duplicate the UI Action and add specific condition, but I would like to achieve this with onload Client Script 

Thanks

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Pbo,

So you want the text of the UI action to change based on the category of incident. Also you don't want to create duplicate UI action with same functionality and have different text.

you can use onLoad client script and sample script below: in the part highlighted in bold search the document id of the button tag

function onLoad(){

if(g_form.getValue('category') == ''){

$j("#resolve_incident").html('Create Technical Problem'); // option 1

//$j("button:contains('Create Problem')" ).html('Create Technical Problem'); // option 2

}

}

If you don't want to rely on the document id since it may change whenever instance is upgraded then use option 2

Option 1: Perform search using document id

Option 2: Searches button with that text and then replace the text

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Pbo,

So you want the text of the UI action to change based on the category of incident. Also you don't want to create duplicate UI action with same functionality and have different text.

you can use onLoad client script and sample script below: in the part highlighted in bold search the document id of the button tag

function onLoad(){

if(g_form.getValue('category') == ''){

$j("#resolve_incident").html('Create Technical Problem'); // option 1

//$j("button:contains('Create Problem')" ).html('Create Technical Problem'); // option 2

}

}

If you don't want to rely on the document id since it may change whenever instance is upgraded then use option 2

Option 1: Perform search using document id

Option 2: Searches button with that text and then replace the text

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Hi @Ankur Bawiskar 

I am using solution 2 for the UI action name change on the Change request form, but it's not working

could you please check once.

MayurGavhane_0-1702983474423.png

MayurGavhane_1-1702983492155.png

 

@MayurGavhane 

Could you raise a new question and tag me there by sharing all the details as this is an old thread?

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

pbo
Mega Expert

Thanks

Solution 2 is perfect