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

rafael_merces1
Giga Contributor

Hi Carlos,



Sorry for the late response. As I stated on my first posts, to achieve what you want, I created an ajax call with a script include. I've sent, more or less, the details of this call on the very same reply where I suggest this approach.



Thanks,


venkatiyer1
Giga Guru

Hi Carlos,


Are you still getting error after checking the scope too. Is there any change in the error message after your last response?



Regards,


Venkat


Yes



Venkat it still isnt working. What would you need me to provide.


here are teh console logs. looks like im not referencing the correct table frmo line 1



Unloaded table does not match current table x_snc_ci_validator_validation_task


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 sndDevPatchGenevaUI: is not UI16 or is already patched.


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 added render event for ui_policy_onLoad


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 [00:00:00.242] form rendered


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 running inline scripts, count: 0


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 runBeforeRender


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 [00:00:00.000] onLoad PCG_RenameOSFields


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 [00:00:00.000] onLoad calcReturn


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 ***************************************************


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 A script has encountered an error in render events


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 TypeError: Cannot read property 'grandTotalRows' of undefined


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 Script ends. Continuing happily


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 ***************************************************


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 [00:00:00.007] onLoad cmdb_task_present_2


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 [00:00:00.001] onLoad PCG_RenameEOLFields


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 [00:00:00.001] ui_policy loaded


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 runAfterAllLoaded, functions: 92


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 fireAllChangeHandlers start


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 fireAllChangeHandlers end


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 late load functions: 3


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 [00:00:00.065] runAfterAllLoaded finished


cmdb_ci_computer.do?sys_id=14562b4d4fb842003aa5e72e0210c72c:99 +-- Parse times


cmdb_ci_computer.do?sys_id=14562b4d4fb842003aa5e72e0210c72c:100 | CSS parse: 20.320000000000164


cmdb_ci_computer.do?sys_id=14562b4d4fb842003aa5e72e0210c72c:101 | JS   doctype: 145.75


cmdb_ci_computer.do?sys_id=14562b4d4fb842003aa5e72e0210c72c:102 | JS at end of page: 144.9449999999997


cmdb_ci_computer.do?sys_id=14562b4d4fb842003aa5e72e0210c72c:103 +-- All parsing: 311.02499999999964


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 after page loaded starting


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 [00:00:00.015] GwtListEditor onTableLoad, tables examined: 10


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:1922 [00:00:00.025] after page loaded complete, functions called: 7


js_includes_ngCommon.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:18414 >>> connection exists, request satisfied


angular_includes_1.4.jsx?v=01-21-2016_1839:110 >>> init cmdb_ci_computer?sys_id=14562b4d4fb842003aa5e72e0210c72c


js_includes_ngCommon.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:18414 >>> connection exists, request satisfied


2js_includes_ngCommon.jsx?v=01-21-2016_1839&lp=Thu_Feb_18_12_39_17_PST_2016&c=4_85:18766 >>>>>> /sn/rp/cmdb_ci_computer/14562b4d4fb842003aa5e72e0210c72c


angular_includes_1.4.jsx?v=01-21-2016_1839:110 factory.snPresence >>> server error @ Thu Mar 03 2016 14:03:14 GMT-0500 (Eastern Standard Time)


venkatiyer1
Giga Guru

Hi Carlos,



Let us try this may be the list is not getting loaded even on load of the page and it is getting delayed. SO you might want to add some sleep time to it.



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);



}



You can increase the timer in ms above to see if that works as well.



Regards,


Venkat