How to make reference field readonly in <sn-record-picker>

amaradiswamy
Kilo Sage

Hi All,

I am creating a referenced field by using <sn-record-picker> directive in service portal. And, it will default to some value

Now, i want to make this field readonly. Is there any way to disable editing of this field?

Regards

Swamy

1 ACCEPTED SOLUTION

dvp
Mega Sage
Mega Sage

You can use


sn-disabled="c.data.variable_name"




Here is an example


<sn-record-picker sn-disabled="c.data.hasRole" field="c.requestedFor" table="'sys_user'" display-field="'name'" value-field="'sys_id'" search-fields="'name'" page-size="100" ></sn-record-picker>


View solution in original post

11 REPLIES 11

I don't see a widget option or parameter to make it read-only so the only way I can think is what I mentioned. Something like:



<sn-record-picker class="user" field="c.ed_user" table="'sys_user'"


                                                  display-field="'name'" value-field="'sys_id'"


                                                  display-fields="'user_name'" search-fields="'user_name,name'" page-size="300"


                                                  options="{cache: true, allowClear: false}"></sn-record-picker>




CSS:


.user:-moz-read-only { /* For Firefox */


      background-color: #888;


}



.user:read-only {


      background-color: #888;


}



I haven't tested this so let me know what you find.


Thank you !!



I am able to make field readonly by using sn-disabled attribute (as per the reply from,dvp)


dvp
Mega Sage
Mega Sage

You can use


sn-disabled="c.data.variable_name"




Here is an example


<sn-record-picker sn-disabled="c.data.hasRole" field="c.requestedFor" table="'sys_user'" display-field="'name'" value-field="'sys_id'" search-fields="'name'" page-size="100" ></sn-record-picker>


Thank you !!



It worked perfectly, i tried with ng-disabled and it didn't work



Is there any documentation available to check for these type of directives and attributes


There is quite a bit of documentation here



GitHub - service-portal/documentation: Here you will find unofficial documentation for the ServiceNo...



I did not see the sn-disabled mentioned anywhere however.