Give write access to a particular field in the form

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 05:55 AM
Hi,
I've requirement to give 'write' access to the user having a particular role to 'Risk Score' field available in "sn_vul_vulnerable_item" table. Please see the screenshot as below (by default this field is read-only):
I've created a role called "sn_vul.vit.riskscore" and an ACL called "sn_vul_vulnerable_item.risk_score" for this. Please see the screenshot as below:
If I'm giving this particular role to the user, still user doesn't have access to edit 'Risk score' field.
Let me know if I'm missing anything or any other action item needs to be taken care.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 06:16 AM
Hi @Bijay Kumar Sha ,
You can do this with help of onLoad client script:
function onLoad() {
//Type appropriate comment here, and begin script below
if(g_user.hasRoles('sn_vul.vit.riskscore'));
{
g_form.setReadOnly('risk_score',false);
}
else
{
g_form.setReadOnly('risk_score',true);
}
}
Please mark helpful if it helped you.
Regards,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 07:38 AM
Hi @shivangi k Thank you for the response.
I've another condition into this role i.e if the "Source" field is 'Manual' then the user should have write access to Risk Score field.
However, I've added this condition in the ACL itself as below screenshot:
So, will the client script still works or do I need to do anything more?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 07:48 AM - edited 01-24-2023 07:49 AM
Either you will you use ACL or Client script in both you can add condition related to source filed and it will work.
For client script:
function onLoad() {
//Type appropriate comment here, and begin script below
var ga=g_form.getValue('source');
if(g_user.hasRoles('sn_vul.vit.riskscore')&& (ga==manual));
{
g_form.setReadOnly('risk_score',false);
}
else
{
g_form.setReadOnly('risk_score',true);
}
}
Regards,
Please mark helpful if it helped you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 09:03 AM
Hi @shivangi k this client script is not able to make ReadOnly False for the 'risk_score' field.
Is this because by default in the dictionary entry 'risk_score' field is ReadOnly True... If this is the case then how to achieve this? It's mandatory to make ReadOnly to 'risk_score' field by default. But only if the user has 'sn_vul.vit.riskscore' role, then it should be editable.