- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2024 06:34 AM
Hi All,
I have an advanced ref qualifier and I am calling a SI
Javascript:new NewIPC().getIPCServersForCurrentUser(current.variables.req_for);
In my SI I am not sure how to receive or map the var req_for. I am only trying this because in my AJAX call it return the expected values but also other record form the CMDB_CI and I am not quite sure why.
Any input appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2024 06:17 AM
I missed earlier that it looks like you are capitalizing the J. It's hard to tell with this editor substitutions, but it should look like this:
Confirm the reference table for this variable is cmdb_ci_server, and that have a variable named req_for that is a reference to sys_user, then you should see the selected user sys_id logged in the Script Include. If the logic in the SI is correct, you should see the correct records logged before the return, then the same should show in the list on the reference variable. None of this is using or requires AJAX or a Catalog Client Script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2024 06:46 AM
Just use a name in the function declaration as an argument, then that name will be available as a script variable
getIPCServersForCurrentUser: function(req_for) {
gs.info('Current user = ' + req_for);
}
Post your SI and more about why you were trying an AJAX call if you're still stuck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2024 07:18 AM - edited 10-08-2024 07:37 AM
The requirement is to return server that are ipc true and are in the same company the requester is in and that the requester is in the ipcadmin group in my console.log I see the 3 servers that are available for this company but in the variable it self it shows all servers in cmdb_ci_server
This was with Ajax call and here is the code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2024 08:36 AM
Hi Brad, how exactly would I use this
getIPCServersForCurrentUser: function(req_for) {
gs.info('Current user = ' + req_for);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2024 08:42 AM - edited 10-09-2024 06:08 AM
You can use the same function for client or server callable like this:
getIPCServersForCurrentUser: function(req_for) {
var userSysId = this.getParameter('sysparm_userSysId') || req_for; // Get the passed user sys_id from CCS or reference qualifier
So userSysId will be the value of the parameter from the CCS if the script was called with that, or the value passed in from the reference qualifier. When reference qualifiers resolve, the format required is 'sys_idIN1....,2...,3....' with the numbers being a list of sys_ids on the referenced table. Since your function is only returning a list of sys_ids to work with the GA call, your reference qualifier should be:
javascript: 'sys_idIN' + new NewIPC().getIPCServersForCurrentUser(current.variables.req_for);