How jQuery works in catalog client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 07:22 AM
Hi,
I am trying to understand, how the jQuery is working in the below script screenshot
trying to find the "app_role_checkbox_val" where i can see it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 08:01 AM
"app_role_checkbox_val" is a class in DOM.
So jQuery is reading all the elements in the DOM where the class is "app_role_checkbox_val". and looping through each element using each function.
Getting the element id of each element and pushing it to an array.
Then after that setting the array value to "app_roles" field.
Please mark as correct answer if this answers your question
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 08:12 AM
i can see only sometimes values are populating in the app_roles , is there any way to track on which bases these element ids are populating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 08:14 AM
@krishna343 If jQuery don't find "app_role_checkbox_val" class in DOM then it will not work.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 08:16 AM
@jaheerhattiwale , how "app_role_checkbox_val" class is available in dom, is there any conditions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 08:22 AM
Do "Ctrl+Shift+i" on the form
Search "app_role_checkbox_val" in Elements
If it is present then you will see it in elements
If it is present then it should populate the app_roles field
If its present and then also not populating then add some delay to make DOM load completely
for that change code as below
setTimeout(function(){
//Add you jQuery code here
}, 5000);
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023