display message for related list

carlosrlara
Mega Expert

I would like to have a pop-up be displayed to an ITIL user when a Configuration Item Related List is present and active.

I have been reviewing and i can add an info message at the top but this can easily be ignored.

What i have come up with a simple alert message

What i have so far is a client script that i need to set for each table.

Presently, we use Server, Computer, and Network gear. When there is an active related list, i would want to display a message

function onLoad() {

    //Type appropriate comment here, and begin script below

   

  alert('Please Review any open CMDB Task Items');

}

1 ACCEPTED SOLUTION

venkatiyer1
Giga Guru

Hi Carlos,



Sorry my bad. Missed a closing parenthesis.



Should be fine now.



Regards,
Venkat




Code Below:




function onLoad() {


getGrandRows();



}


function getGrandRows() {


setTimeout(function(){


var list = GlideList2.get("x_snc_ci_validator_validation_task");


// You can get the ID of related list from the developer tool bar. Check for the div holding the content and grab the list id.


if(list && list != undefined) {



var numberOfCMDBItems   = list.grandTotalRows; // This parameter tells us number of rows in that list. Which should be greater than zero for alert


}


if(numberOfCMDBItems)


alert("'Please Review any open CMDB Task Items");



}, 3000);



}


View solution in original post

22 REPLIES 22

carlosrlara
Mega Expert

right now when i put alerts



i never get these two alerts. which tells me it never runs. it skips all the way to the last alert 'alert("'Please Review any open CMDB Task Items");'



var numberOfCMDBItems= list.grandTotalRows; // This parameter tells us number of rows in that list. Which should be greater than zero for alert


  alert("cmdblist");



  //g.list.addfilter ("active=true");


  //alert ("addfilter");




  if (numberOfCMDBItems > 0 ) {


        alert ("#cmdb");


venkatiyer1
Giga Guru

Hi Carlos,



It says cant read the grandTotalRows Of undefined that means it is not grabbing the list value. Can you check the id of the list. Please share the screenshot of the html page of the container that is holding the CMDB items. I can suggest the id of the screenshot. Alternatively, look for a div container that is holding the whole section in related list. Take the id and remove any expanded or extra string at the end of id. You should get the list id? Once you console log the list you should see like what i have in screenshot.



Thanks


Venkat


venkatiyer1
Giga Guru

Hi Carlos,



var list   =   GlideList2.get("id of list")   will return error message if there are no items. it returns undefined if the list has no items. So that should be enough to alert as well if there are no CMDB items in related list. If the list is defined then go about finding the grandTotalRows. That logic should work perfectly. Sorry my bad, i should have checked the no item list condition too.



Code below and condition is ITIL user.


function onLoad() {



var list = GlideList2.get("x_snc_ci_validator_validation_task");


// You can get the ID of related list from the developer tool bar. Check for the div holding the content and grab the list id.


if(list && list != undefined) {



var numberOfCMDBItems   = list.grandTotalRows; // This parameter tells us number of rows in that list. Which should be greater than zero for alert




alert("'Please Review any open CMDB Task Items");



} // Instead of alert you can do glide window too.




Venkat


rafael_merces1
Giga Contributor

Hi Carlos,



Have you been able to make this work?



Thanks,


carlosrlara
Mega Expert

No, i havent been able to get what venkat provided to work



any ideas rafael?



I can't imagine this is a difficult ask.