Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to display only my assets list which are assigned to me when i select Asset field in the record producer ?

hemachandra2
Tera Contributor

Hi All,

how to display only my assets  list which are assigned to me when i select Asset  field in the record producer ?

Please help me to achieve this

 

Thanks 

Hemachandra

 

14 REPLIES 14

Basically you create a script include that returns a query string, and in the reference qualifier you call on it like this:

javascript: new global.UsersComputers().getUsersAssignedComputers(current.variables.user);
// the name of the variable must match the User variable on your record producer

 

Example script include:

var UsersComputers = Class.create();
UsersComputers.prototype = {
    initialize: function() {
    },

	getUsersAssignedComputers: function(user)
	{
		var query = 'install_status=1^assigned_to=' + user;
		return query;
	},
    type: 'UsersComputers'
};

Chaitanya Redd1
Tera Guru

Hi Hemachandra,

 

You can try below code.

You can use reference qualifier on Assets variable.

 

Reference qualifier on Assets variable:

javascript: 'assigned_to='+current.variables.<<user variable name>>; //replace with user variable

 

 

If I have answered your question, please mark my response as correct and/or helpful.

Thanks,

Chaitanya

Hi Chaitanya,

Thanks For the response 

And in that i need one thing that Basically Asset variable created on asset table, so but here i need to display hardware assets which are assigned to that particular user only

 

Thanks

Hemachandra

Hi Chaitanya

I tried this but it won't works for me

Can you please provide me the sample code for script include , it will helpful me to achieve this?

Thanks

Hemachandra

 

Hi Chaitanya,

Thanks For the response 

And in that i need one thing that Basically Asset variable created on asset table, so but here i need to display hardware assets which are assigned to that particular user only

So how i add that condition to above code?

 

Thanks

Hemachandra