cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a simple, fast way to make an Activiti (Alfresco BPM) form ready-only for specific users?

joeblue
Champ on-the-rise
Champ on-the-rise

I am building a prototype app for a performance review process. The process includes several actors working with basically the same form. If you go back to its paper-based roots, one actor would complete his part of the form, then pass it on to another actor to review what the first actor did, and then fill out her part of the form before submitting it to the department. I'd like to do this in the app, but I need to somehow control which fields the different users can only see (i.e., read-only) and which fields the user can change based on the users role in the process.

I asked about making forms/fields read-only in both the Alfresco support form and the Activiti community, but the three answers I received are not simple.

1. Use the same form in all steps, and use JavaScript to control the .disabled property of the HTML document object to essentially make the appropriate fields read-only. My form has about 100 fields, so I'd have to do that for every field when the form is rendered depending on which role the user plays. Doable, but not simple and probably time-intensive to get it right.

2. Create a different form for each user type, using the Display Value/Text fields for read-only fields. That would mean I would need to build up to 4 different versions of the same form and keep them in sync. Also doable, but not simple, time-intensive to get it right, and not very modifable (1 change request requires 4 changes).

3. Build a Java class that over-rides the built-in types and rendering services so that they have a readOnly property that I can easily change. Also doable (although I'm not a Java pro), and possibly a good long-term solution, but definitely complex and probably not doable in the timeframe I have to build the prototype app.

At this point, I'm going to pursue option 2 because sharing the same form across tasks means everyone will be able to see every entry made by another user in the Completed Tasks and because I found that using the HTML document object in the JavaScript doesn't exactly work the way I'd like it to work.

But, if someone knows of a way to click a button to automatically generate a read-only version of a form, please let me know.

Another idea would be to add a read-only checkbox in the Field editor window (similar to the required checkbox)—that would let me build the form once, copy it for each user type, and then check that read-only box for all fields that should be read-only for the associated task. I recognize the complexity in actually making that happen, but one can dream!

Thanks.

-Joe

1 ACCEPTED ANSWER

gdharley
Elite Collaborator
Elite Collaborator

Hello Joe,

In my opinion, option 1 (using Javascript to set the disabled field) is the correct solution. You mentioned you didn't want to do this because you had 100+ fields. The way around this is to target the container element and use Javascript to disable all contained "inputs".
The following JSFiddle demonstrates the approach: JQuery Disable Div - JSFiddle 

Hope this helps.
Regards,
Greg

View answer in original post

2 REPLIES 2

gdharley
Elite Collaborator
Elite Collaborator

Hello Joe,

In my opinion, option 1 (using Javascript to set the disabled field) is the correct solution. You mentioned you didn't want to do this because you had 100+ fields. The way around this is to target the container element and use Javascript to disable all contained "inputs".
The following JSFiddle demonstrates the approach: JQuery Disable Div - JSFiddle 

Hope this helps.
Regards,
Greg

joeblue
Champ on-the-rise
Champ on-the-rise

Greg,

Thanks for the tip to target the container and JSFiddle demonstration. I didn't get a chance to try it in my app because I had already gone down the option 2 path—create a different form for each user type, using the Display Value/Text fields for read-only fields. But it's something I'll look into when I get a chance to refactor my app. Right now I have to focus on shipping what I've done so far.

Thanks again.

-Joe