How to auto populate the Application name in catalog item

Arun91
Tera Contributor

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.

7 REPLIES 7

Arun91
Tera Contributor

Hi,

Problem is it is not getting requestor name 

You should pass requested for details from reference qualifier

 

I have already added first line in post

How to call reference qualifier. Please check it and do changes correctly

Updated the code shared by @Mani A 

Let me know if you need more help, send me invite in inbox, we can review this together.

It's difficult to resolve such code without know the backend custom table structure, you have drill down and pin point the issue.

 

var r = Class.create();
r.prototype = {
    initialize: function() {
    },
    TypeAccessRoles1: function(u_user_name) {
        var roles = [];
       	var y = [];
        var finalArr=[];

		var x = new GlideRecord('u_uam_application_user_roles');
		// replace the "assigned" with correct column name as in table
		x.addEndodedQuery("assigned"+u_user_name+'^u_app_nameISNOTEMPTY');
        x.query();
		// iterate the resultset, use if for single record and use while for more that one record
		while(x.next()){
        		y.push(x.u_app_name.toString());
        		var app = new GlideRecord('cmdb_ci_appl');
        		app.addEncodedQuery("app.sys_idIN"+y); // are you expecting multiple application sys_is here or just one
        		app.query();
				if(app.next()){
					finalArr.push(app.sys_id.toString());	
				} // if closed
		} // while closed
        return finalArr.join(",");
},
    type: 'r'
};

 

 

-Thanks,
AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution