List CI's owned by selected user

Harry Campbell2
Mega Guru

Hello Everyone,

I want to list all CI's owned by a selected user on a leaver form.

This is how I would like it to work:

1. User Opens our User Leaving catalog item and selects the name of the user that is leaving in the 'impacted_user' variable.

2. Either on the same page or in a popup window, I want to list the CI's that the person leaving is an owner of, with the option to set a new owner for each. (If the user is not an owner of any CI's then nothing would be shown)

Could someone please let me know how this is possible, I think some form of UI page would be the best bet, I just cant get my head around it.

Many Thanks

Harry

15 REPLIES 15

Hi Russell,



All is well here, hope all is well with you. I've got the ServiceNow position full time so I can finally start making some real changes . Pity we never got to get cracking with all the identity stuff we were wanting..... we are still a while away from that



To keep it simple I do want ALL assets to go from person a to person b. Person b would be defined on the leaver form and would be approved by the current owner or their line manager. I think I'll have a play around with that. How would a ref field handle multiple items though?


Kalaiarasan Pus
Giga Sage

Why not simplify the requirement further? How about using a list collector to show the CI's owned by the user? If yes, you just need to define the reference qualifier of the list collector and this would not require much coding either.



The solution would also be much easier to maintain during future upgrades.


Actually a read only List collector is not a bad idea. Can this change dynamically in the page when the impacted_user field is changed? I've not had much luck with changing list collectors dynamically in the past.



For this I have just tried this:



function onChange(control, oldValue, newValue, isLoading) {


  var collectorName = 'ci_ownership';


  var filterString = 'owned_by=current.variables.impacted_user.getValue()';



  window[collectorName + 'g_filter'].reset();


  window[collectorName + 'g_filter'].setQuery(filterString);


  window[collectorName + 'acRequest'](null);


}



But doesnt't seem to be working.



Thanks


Harry


function onLoad() {


    //Apply a default filter to the list collector variable


    var collectorName = VARIABLE HERE;


    var filterString = QUERY HERE;


    //Hide the list collector until we've set the filter


    g_form.setDisplay(collectorName, false);


    setCollectorFilter();


   


    function setCollectorFilter(){


          //Test if the g_filter property is defined on our list collector.


          //If it hasn't rendered yet, wait 100ms and try again.


          if(typeof(window[collectorName + 'g_filter']) == 'undefined'){


                setTimeout(setCollectorFilter, 100);


                return;


          }


          //Find the filter elements


          var fil = gel('ep');


          //Hide the filter elements by un-commenting the following lines


          /*fil.rows[0].style.display = 'none';


          fil.rows[1].style.display = 'none';


          fil.nextSibling.rows[0].style.display = 'none'; //Filter description text*/


         


          //Reset the filter query


          window[collectorName + 'g_filter'].reset();  


          window[collectorName + 'g_filter'].setQuery(filterString);  


          window[collectorName + 'acRequest'](null);  


          //Redisplay the list collector variable


          g_form.setDisplay(collectorName, true);


    }


}


You don't need to do this now. If you are on Helsinki, List collector supports reference qualifier similar to reference fields.