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

venkatiyer1
Giga Guru

You don't need to make Ajax call for this as the form has the information.



Regards,
Venkat


carlosrlara
Mega Expert

Venkat,



wow, this seems much simpler. Thanks. I will try and let you know how it goes. Thanks!


carlosrlara
Mega Expert

Venkat,



i bypassed the rule right now just to ensure the alert works


here is what i have



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.


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



if (numberOfCMDBItems > 0 ) {



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



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




The alert still fired even though there were no CMDB Validation Tasks present.



Any ideas?


venkatiyer1
Giga Guru

Hi Carlos,



We might want to debug to ensure the list id is correct. If you have chrome toolbar, ensure you select that frame where your form is displaying. Post that



Screen Shot 2016-02-10 at 2.32.28 PM.png


Try this line below. You should see what I have in the log. And then try list.grandTotalRows. I took a sample list to do this and got the answer. hope this helps..


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


carlosrlara
Mega Expert

here are the console logs. i have italicized where the script errored out



added render event for ui_policy_onLoad


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 [00:00:00.244] form rendered


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 running inline scripts, count: 0


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 runBeforeRender


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 [00:00:00.001] onLoad PCG_RenameOSFields


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 [00:00:00.000] onLoad calcReturn


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 ***************************************************


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


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


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 Script ends. Continuing happily


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 ***************************************************


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 [00:00:00.000] onLoad cmdb_task_present_2


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 [00:00:07.182] onLoad Onload_CMDB Task


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 [00:00:00.001] onLoad PCG_RenameEOLFields


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 [00:00:00.002] ui_policy loaded


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 runAfterAllLoaded, functions: 92


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 fireAllChangeHandlers start


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 fireAllChangeHandlers end


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


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 [00:00:00.053] runAfterAllLoaded finished


cmdb_ci_computer.do?sysparm_nostack=true&sys_id=001db4c64fdc0a003aa5e72e0210c7af&sysparm_record_tar…:99 +-- Parse times


cmdb_ci_computer.do?sysparm_nostack=true&sys_id=001db4c64fdc0a003aa5e72e0210c7af&sysparm_record_tar…:100 | CSS parse: 20.115000000000236


cmdb_ci_computer.do?sysparm_nostack=true&sys_id=001db4c64fdc0a003aa5e72e0210c7af&sysparm_record_tar…:101 | JS   doctype: 89.89499999999998


cmdb_ci_computer.do?sysparm_nostack=true&sys_id=001db4c64fdc0a003aa5e72e0210c7af&sysparm_record_tar…:102 | JS at end of page: 143.31999999999994


cmdb_ci_computer.do?sysparm_nostack=true&sys_id=001db4c64fdc0a003aa5e72e0210c7af&sysparm_record_tar…:103 +-- All parsing: 253.34500000000003


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 after page loaded starting


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 [00:00:00.016] GwtListEditor onTableLoad, tables examined: 10


js_includes_navpage15.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:1922 [00:00:00.023] after page loaded complete, functions called: 7


js_includes_ngCommon.jsx?v=01-21-2016_1839&lp=Thu_Jan_14_04_37_39_PST_2016&c=3_42:18414 >>> connection exists, request satisfied