Hide list collector variable after values are selected

ServiceNow Adm1
Giga Contributor

Hi All,

I have a list collector to allow user to select multiple values. When a user selects some value and move them from available to selected slush bucket and save the form, after the form loads, this list collector should be read-only.

How can I do this? I am unable to do it with UI policy which we check if field is not empty then make read-only but how to check for this one?-

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

have you tried with onload client script ?

 

eg:

 

function onLoad() {

if(g_form.getValue('variable name').toString() !=''){
g_form.setReadOnly('variable name',true);
}

}

View solution in original post

3 REPLIES 3

Harsh Vardhan
Giga Patron

have you tried with onload client script ?

 

eg:

 

function onLoad() {

if(g_form.getValue('variable name').toString() !=''){
g_form.setReadOnly('variable name',true);
}

}

Anil Shewale
Mega Guru

Hi

Write Onsubmit /update client script like blow on Catalog Task table.

Note: In my case I have taken list collector as sys_user table. Change the highlighted element ids based on your requirement.

function onLoad() {  

  document.getElementById('user_select_0').style.visibility ="hidden";

 

  document.getElementById('user_select_0_title_row').style.visibility ="hidden";

 

  document.getElementById('user_sys_user').style.visibility ="hidden";

 

  document.getElementById('user_select_0_search_row').style.visibility ="hidden";

 

}  

if it not help refer the following thread .

https://community.servicenow.com/community?id=community_question&sys_id=1d4fcbe1dbdcdbc01dcaf3231f96...

https://community.servicenow.com/community?id=community_question&sys_id=d2bebc15db8d17842e247a9e0f96...

https://community.servicenow.com/community?id=community_question&sys_id=a9f58361db1cdbc01dcaf3231f96...

 

If it help mark helpful or correct 

Thanks and regards

Anil

Indrajit
Mega Guru

hey ,

try below code it works,

 

function onLoad() {

g_form.setReadOnly('variable name',true);

}

 

kindly mark Correct and Helpful if applicable.

Regards,

Indrajit.