- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2024 06:50 AM
Hello,
I am attempting to auto-populate variables in a multi-row variable set based on the logged in user whom is accessing the form. If the logged in user is listed as the owner of a business service, the service name, class, owner fields will auto-populate from all of the records the user owns on the cmdb_ci_service table. Below is my onLoad Catalog Client Script and Script Include which isn't working. Any help would be appreciated!
Client Script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2024 06:58 AM - edited ‎04-04-2024 07:24 AM
Hi Chelsea,
In your Script Include, ownerID is undefined, so you'll need a line like this prior to using it in the addQuery:
var ownerID = this.getParameter('sysparm_ownerID');
Also when building the obj, since your first two MRVS variables are reference, they need the sys_id, not the displayValue, so try:
obj.service = service.getUniqueValue();
obj.managed_by = service.getValue('managed_by');
Beyond that, add some alerts to your client script, and gs.info lines to the Script Include so that you can confirm that each is running, the value passed between client and server and back, and if the GlideRecord is returning the expected records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2024 06:58 AM - edited ‎04-04-2024 07:24 AM
Hi Chelsea,
In your Script Include, ownerID is undefined, so you'll need a line like this prior to using it in the addQuery:
var ownerID = this.getParameter('sysparm_ownerID');
Also when building the obj, since your first two MRVS variables are reference, they need the sys_id, not the displayValue, so try:
obj.service = service.getUniqueValue();
obj.managed_by = service.getValue('managed_by');
Beyond that, add some alerts to your client script, and gs.info lines to the Script Include so that you can confirm that each is running, the value passed between client and server and back, and if the GlideRecord is returning the expected records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2024 10:45 AM
Thank you! I few tweaks and adding that line. I was able to get it working. I was so close!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2024 11:47 AM
Great to hear - and you are welcome!
Connect with me https://www.linkedin.com/in/brad-bowman-321b1567/