make fields editable when impersonated with specific user and other field in form should be readonly
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2024 09:41 PM - edited ‎04-09-2024 09:42 PM
when i impersonate with ex: abel tuter all the fields which are mandatory for abel tuter in the incident form should be editable and other fields which are not mandatory for him should be readonly.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2024 02:07 AM
Hi Chaithanya,
We can create a onLoad client script with the below code.
var user = gs.getSession().getUser();
var table = g_form.getTableName(); //get the table name of the current form
var isStrict = GlideProperties.getBoolean('glide.soap.strict_security');
var soapSecurity = new GlideSOAPSecurity();
soapSecurity.setStrictSecurity(isStrict);
var gr = new GlideRecord(table);
// are we allowed to see this table's fields?
var fields = [];
var elems = gr.getElements();
for (var i = 0; i < elems.size(); i++) {
var elem = elems.get(i);
var name = '' + elem.getName();
var field = {};
if(soapSecurity.canWrite(gr, name)){
g_form.setReadOnly(name, false); //make the field editable
}
}
Please test all the test cases before implementing this script.
If my answer has helped with your question, please mark my answer as accepted solution and give a thumbs up.
Best regards,
Tharun Kumar