Make child table Read-only based on parent state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 07:40 PM - edited 05-21-2024 07:41 PM
I have a requirement to make related list tables ready only based on associate parent state.
Per example if program is completed or approval states then I need all associate related list tables like projects, benefit plan, benefits plan breakdowns, cost plan, cost plan breakdown fields read only for employee manager role users.
Ui policy or Clint script is preferred way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 10:03 PM
Hi @VSN
Create a Onload Client Script on your table.
Modify the script as per your needs ,,, check table names also...
if (!g_user.hasRole('employee_manager')) {
return;
}
// Read the state of the program
var programState = g_form.getValue('state');
// Define the states where the lists should be read-only
var readOnlyStates = ['completed', 'approval'];
// Function to make related list read-only
function setRelatedListReadOnly(listName) {
// Disable the new button
g_form.setRelatedListControls(listName, false, false);
// Disable the entire related list
g_form.setRelatedListEditStatus(listName, false);
}
// If program state is in the read-only states list, make the related lists read-only
if (readOnlyStates.includes(programState)) {
setRelatedListReadOnly('projects');
setRelatedListReadOnly('benefit_plan');
setRelatedListReadOnly('benefit_plan_breakdowns');
setRelatedListReadOnly('cost_plan');
setRelatedListReadOnly('cost_plan_breakdown');
}
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 10:04 PM
Hello @VSN ,
You can create ui policy or client script on child table that will check if the condition is matching and then make the fields read-only. You can add g_user.hasRole('employee_manager') condition for role validation. Please refer the below post for more understanding -
If my answer solves your issue, please mark it as Accepted ✔️ and Helpful 👍 based on the impact.