Service Portal - Getting list of records based on a variable on catalog item

Harry Campbell2
Mega Guru

Hello All,

I need a bit of help with our 'User Leaving' item. I have asked this previously but I now require a more Service Portal friendly solution. The solution we had when using CMS wasn't great - and wont work at all in the Service Portal, so I'm on the hunt for ideas.

We have a User Leaving item with an 'impacted_user' reference variable. This references the sys_user table.

When a user is entered into this field, I need to display a list of configuration items that the user owns on the catalog item. Could anyone share any ideas on how this could be achieved?

Many Thanks

Harry

1 ACCEPTED SOLUTION

I was going to write it down for you, but I remember this one, and why rewrite something that is already written 😃
Embedding widgets in Service Catalog - ServicePortal.io - Service Portal, CMS, and Custom Apps



Let me know if you have more questions




//Göran


View solution in original post

8 REPLIES 8

I had no idea that was possible. That should make things a lot easier.



I can have a play with this. How would the widget reference the impacted_user variable though?


I was going to write it down for you, but I remember this one, and why rewrite something that is already written 😃
Embedding widgets in Service Catalog - ServicePortal.io - Service Portal, CMS, and Custom Apps



Let me know if you have more questions




//Göran


Thanks for this Goran.



Marked as correct - I can definitely work with this.



Surprised I haven't come across this before. It is a bit of a gem!


Hi Goran,



I'm hoping you can help me with the last part of this. I have built the widget but having problems passing the variable value from the client script into the query in the server script:



Client Script:


function($scope) {


      var c = this;    


      //Watch for changes in the name variable


      $scope.$watch(function () {


                  return $scope.page.g_form.getValue('impacted_user');        


});


}


$scope.data.impacted_user = $scope.page.g_form.getValue('impacted_user');



Server Script:


var leaver = input.impacted_user;



var fileshare = new GlideRecord("cmdb_ci_storage_fileshare");


fileshare.addQuery("owned_by",leaver);


fileshare.query();



data.fileshares = [];


data.fileshareIDs = "";


while (fileshare.next()) {


  var file = {};


  file.name = fileshare.getDisplayValue();


  data.fileshares.push(file);


  data.fileshareIDs += "," + fileshare.getUniqueValue();


}



Can you help at all with this? Everything else works as expected, I just cant pass the variable value into the query.



Many Thanks


Harry