How to auto populate the Application name in catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2024 08:57 AM
Hi Team,
We have created a catalog item form which contains requested for and application name.
Requested for field is referencing sys_user table and application name field is querying cmdb_ci_appl table.
I have another two custom tables named as xxx and yyy.
cmdb_ci_appl table has all the application that is mapped with table xxx. In table yyy the data which is present in table xxx along with the assigned user will present in table yyy
Now my requirement is when user is submitting the request, user will select the requested for based on the requested for input it should display the application name details.
Kindly help me on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2024 09:48 AM
Hi @Arun91 ,
Write catalog client script [ onLoad or onChange ] whichever is applied.
In the script, read the user from yyy and get the match record from xxx and read the application from cmdb_ci_appl.
Draft some script code and share so we can help.
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2024 07:38 PM
Sample code:
Write reference qualifier on application name variable like
Javascript: new scriptInclude().fName(current.varibales.requestedFor);
In script include function..
function :fName(user)
{
var x =new GlideRecord("yyyy")
x.addEndodedQuery("assigned"+user+'^applicationsISNOTEMPTY");
x.query()
var y=[]:
y.push( x.applications.toString());
var app=new GlideRecord("cmdb_ci_app")
app.addEncodedQuery("app.sys_idIN"+y)
app.query();
Var finalArr=[];
finalArr.push(app.sys_id.toString();
return finalArr.join(",");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2024 08:06 PM
Hi,
I have tried it but still I am able to see all the application.
Code which I have written:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2024 10:06 PM
I had given sample code..please do changes with correct field names..
where are you passing user_name
parameter in function ?
typeAccessRoles1: function (user_name)
X.addEndodedQuery("u_user_name="+user_name+"^u_app_nameISNOTEMPTY");
x.query()
While(x.next())
Also use while loop after query statement
next in second gliderecord useCorrectfiedlName for app..
also use while loop after query statement..
At the end return "sys_idIN"+finalArr.join(",");