how to make a field read only using ui action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 04:22 AM
Hi,
I have a requirement where i need to create the "assign to me" button on interaction form, when some user clicks that button , then the interaction should get assign to him & the "assigned to" field should become read only.
The interaction is getting assigned correctly, but when i try to add read only code then it is not working.
Below is the code:
show insert is true
show update is true
form button is true
condition: current.active==true &&gs.getUser().isMemberOf(current.assignment_group)
script :
current.assigned_to = gs.getUserID();
current.update();
action.setRedirectURL(current);
how to ensure that the interaction gets assigned when button is clicked & the assigned to field become read only?
Kindly, help!
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 04:57 AM
Hi there,
The issue is that you are not going to be able to persist keeping that value read only with the UI Action. You’ll need to do it in concert with a UI Policy that sets the field read only on your condition, or a Client Script if you can’t craft the condition in condition builder.
These all would only apply on the form view, the truest way to stop this would be to manage it via a write ACL. Otherwise this could be edited from a list for example.
Hope this helps.
Kind regards,
Astrid Sapphire
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 06:57 AM
Hi, I would recommend to write the UI Policy. Write the condition as Assigned To is not empty and the UI Policy action as assigned to is Read Only state. It's a best approach don't write code in UI Action.
Suresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 07:14 AM - edited 11-23-2022 07:15 AM
Hello @SK41 ,
Do one thing try to make this UI action completely client side like below
check the client check box and then add your on click function and try this script below
functionyour_click_function_name()
{
g_form.setReadOnly('assigned_to',true);
gsftSubmit(null, g_form.getFormElement(), ''); //MUST call the 'Action name' set in this UI Action
}
if(typeof window == 'undefined')
runBusRuleCode();
//Server-side function
function runBusRuleCode(){
current.assigned_to = gs.getUserID();
current.update();
action.setRedirectURL(current);
}
Hope this helps
Mark my answer correct if this helps
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 07:18 AM
Click on client checkbox of your created UI action and create a function inside UI action and write below field:
function readonly(){
g_form.setReadOnly("assigned_to",true);
}
readonly();
Write this code below after your validation.