- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2017 06:12 AM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2017 06:31 AM
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>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2017 06:18 AM
You can put an id or class tag on it (with a name) and use CSS something like this:
.className:-moz-read-only { /* For Firefox */
background-color: yellow;
}
.className:read-only {
background-color: yellow;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2017 06:20 AM
Hi Tomasi,
Thanks for your reply !!
I want to make the field readonly so user can't edit the field.
Regards
Swamy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2017 06:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-23-2017 06:27 AM
The styles will work when field is readonly.
But, my query is to how to make this field readonly
Widget script:
<div class="flex-grow flex-row items-center">
<label style="padding-right:10px;">Approver</label>
<div class="rp">
<sn-record-picker 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>
</div>
</div>
Client
function($scope,$location, spUtil, amb, $http,$timeout,$uibModal) {
/* widget controller */
var c = this;
c.ed_user = {
displayValue: c.data.useraname,
value: c.data.usersys_id,
name: 'user'
}
}
Server
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.table =$sp.getParameter('table');
data.usersys_id = gs.getUserID();
data.useraname = gs.getUser().getDisplayName();
})();