Script to run on list view

saran4
Kilo Guru

How to run a script on List View without onCellEdit. Like in a sense if we load a list view of table the script should run.

Thanks in Advance.

1 ACCEPTED SOLUTION

Hi,

then you can check this link where I shared solution 3 years ago

Display Info message only on list layout

The script section of query business rule will check and show info message only on list and not on form

var index = gs.action.getGlideURI().toString().indexOf('u_tableName_list'); // give the table name here

if(index == -1){
	// it means it is form
}
else{
	gs.addInfoMessage("click on the desired drink to know its nutritional value");
	// it means it is list
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Hi,

I believe that's not the complete requirement.

Can you provide complete business requirement with an example?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

There is a table which lists all the drink of a particular shop. In the list view we can only see name of the drink and image of the drink as I personalized the list view. To know the nutritional values of any particular drink user has to click on the particular record.

so now I want add an info message in the list view as "click on the desired drink to know its nutritional value". At the same time I don't want this info message to be displayed on the form view.

Hi,

then you can check this link where I shared solution 3 years ago

Display Info message only on list layout

The script section of query business rule will check and show info message only on list and not on form

var index = gs.action.getGlideURI().toString().indexOf('u_tableName_list'); // give the table name here

if(index == -1){
	// it means it is form
}
else{
	gs.addInfoMessage("click on the desired drink to know its nutritional value");
	// it means it is list
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader