I created the view and added the client script still its not changing assigned to to owner .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2025 11:31 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 02:07 AM - edited 03-10-2025 02:27 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 02:18 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 02:24 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2025 02:39 AM
Hi @mishrarakes I see that you have used - g_form.setLabel('assigned_to','Owner'); Please use 'setLabelOf' instead-
g_form.setLabelOf('assigned_to','Owner');