I created the view and added the client script still its not changing assigned to to owner .

mishrarakes
Tera Contributor
1)Create one view in the SCTASK Form for My Request.
2)Only for this view "Assigned to" Label  will change as "Owner" in the SCTASK form.
3)In the catalog Item create two new variables
                                                            1)Food Preferences(Select box type—->two options-->Veg, non-veg
                                                             2)Food list(select box type--->If food preferences select Veg, then Food List option should be milk,Oats,rice
                                                                                                                    ---> If food preferences select non-Veg, then Food List option should be egg,chicken,mutton.
 
 
4)Whenever the SCTASK will be resolved then one notification will trigger the request for person.(Instead of global one, Create one custom notification and one  header and footer).
 
 
here I am attaching the ss of script.
5 REPLIES 5

_Gaurav
Kilo Sage

Hi @mishrarakes 
Can you check the view name is written correctly?
Whenever we create any view, the backend name changes automatically in the system.

So, instead of writing 

if(viewName === 'My Request')

Try writing in line 5

if(viewName == 'my_request')

 

Please mark this as a solution and helpful if this resolves your query.

Thanks!

Vasanthi_L
Tera Contributor

Hi Mishrarakes,

 

To populate the 'Assigned to' field when the 'View' is changed:

  • Uncheck the 'Global' option and specify the view name you created.
  • Then, write an onLoad() Client Script as per your requirement.

For reference, I have provided the attachment.

 

Regards,
Vasanthi Lankada

 

Vasanthi Lankada

Ankur Bawiskar
Tera Patron
Tera Patron

@mishrarakes 

so what's not working?

Did you check you are comparing the correct view name?

also use == and not === during comparison

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

GopikaP
Mega Sage

Hi @mishrarakes I see that you have used - g_form.setLabel('assigned_to','Owner'); Please use 'setLabelOf' instead-

g_form.setLabelOf('assigned_to','Owner');