- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 07:04 AM - edited 03-25-2025 07:12 AM
Hi,
The requirement is that when a change task of type=peer review is created on a change, the state needs to be read only for everyone except admin and based on the result of the field peer review result (pass or fail) the state needs to be set to closed. Note: The state field on the change_task table comes from the task table.
I have made an onChange client script for setting the state to closed if peer review result=pass or fail
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
if (newValue=='Pass'||newValue=='Fail'){
g_form.setValue('state', 3);
}
}
I have also made another onLoad client script for state to be read only for all except admin
function onLoad() {
//Type appropriate comment here, and begin script below
if (!g_user.hasRole('admin')){
g_form.setReadOnly('state', true);
}
}
However, making the onLoad client script has set the state to read only for all types of change tasks and not just the peer review type.
So, I made a dictionary override but then the state was set to read only for this type of task but it was for everyone including admin.
Is there any way to make the state read only another way for all except admin for this change task type. Doing the dictionary override does not give admin right to change it back, doing the onLoad client script makes it for all the task types.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 07:29 AM
You just need to do one more check in your OnLoad client script to check the Change task type. PFB.
function onLoad() {
var role_flag = g_user.hasRole("admin");
var type = g_form.getValue("change_task_type"); // get the task type
g_form.addInfoMessage("Role Flag : " + role_flag);
g_form.addInfoMessage("Task type : " + type);
if (!role_flag && type == "implementation") { // check the task type. I've used "Implementation" type. You can change it to "Peer review"
g_form.setReadOnly('state', true);
}
}
Output:
Hope this helps.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 07:29 AM
You just need to do one more check in your OnLoad client script to check the Change task type. PFB.
function onLoad() {
var role_flag = g_user.hasRole("admin");
var type = g_form.getValue("change_task_type"); // get the task type
g_form.addInfoMessage("Role Flag : " + role_flag);
g_form.addInfoMessage("Task type : " + type);
if (!role_flag && type == "implementation") { // check the task type. I've used "Implementation" type. You can change it to "Peer review"
g_form.setReadOnly('state', true);
}
}
Output:
Hope this helps.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 07:39 AM
@J Siva thanks so much, that has resolved the problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 07:48 AM
Glad to hear that it helped!