The CreatorCon Call for Content is officially open! Get started here.

Add client script event to embedded list in Form view?

georgechen
Kilo Guru

Hello folks,

A previous discussion has been post at https://community.servicenow.com/message/1246525?et=watches.email.thread#1246525   about hiding a specific class in an embedded list, in order to control further to the embedded list, I was wondering if it is possible to insert a client event to the embedded list, for example,

When a client double click 'insert a new row...', this fires the new event

find_real_file.png

find_real_file.png

Perhaps to pops up an alert, indicating "You are able to enter a string field type", etc.

with this new event, I actually attempt to remove certain css class (despite this has been answered in the forum post above which applies to form load client script).       In the script, it would need to fetch the DOC object like getElementById() or getElementByClassName()

Any advice would be appreciated.

Kind regards,

George

4 REPLIES 4

Gaurav Bajaj
Mega Sage

Hi, George,



You can give it a try with onCellEdit client script. This will work when you change the value on the embedded list not before entering the data.


I am afraid this would also get triggered on the actual list apart from the embedded list.





Thanks


Gaurav


Hi Gaurav.


Thanks for the advice.   Actually the script would need to fire before the record is updated so that it can remove the '+' sign by executing the below script



window.setTimeout(hideSign,5000); //wait to load embeded list on the form


function hideSign(){



function WaitSeconds() {


}


var list=document.getElementsByClassName('list_odd list_row list_add');



//alert(list.length);


if (list.length>0) {


for (var i = 0; i < list.length; i++) {


if(list[i].id) {


window.setTimeout(WaitSeconds,5000); //wait to load embeded list on the form


      document.getElementById(list[i].id+'_edit').style.display="none";



}



}


}


}





The script basically looks for "list_odd list_row list_add" class, and then try to iterate the elements within this class.   If an element has an id, then set its style.display to "none" in other words, hide it.



Thanks for your advice any.


Regards,


hi George,



Is your comment answering ur own question?


While researching on other issue, i came across this post, i am able to add a click event on each of the element underneath list[i].



thanks.


Thanks Bryan.   the comment was a latter capture of finding so as to hide the '+' on load, and yet addresses the issue when inserting a new row on the fly. (the '+' still shows)


Thanks,