Page 1 of 1

Disable an input form (property group element) for any user

PostPosted:Tue Sep 01, 2015 3:00 pm
by intel74
hi all
i'm using 6.3 community, please can anyone help my!!!
Is there a way to have a property group element enabled only for some user and disabled for others users??
I define an automation rule so after uploading a file automatically the system add a property group and a windows appear with some fields to fill (invoice number, date, note, etc). I'll an input field was ReadOnly for some users so i define the automation rule with 2 action, in this way:
1) AddPropertyGroupToWizard, to add property and to show the form to fill
2) ExecuteScripting for make an input field readonly=false/true based on ROLE

I've no error but input field was always readonly=true...
Code: Select all
import com.openkm.api.OKMPropertyGroup;
import com.openkm.api.OKMRepository;
import java.util.*;
import com.openkm.dao.DatabaseMetadataDAO;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.bean.form.FormElement;
import com.openkm.bean.form.Input;
import com.openkm.bean.form.Select;
import com.openkm.bean.form.Option;
import com.openkm.util.PathUtils;
import com.openkm.util.FileUtils;
import com.openkm.api.OKMDocument;
 
String grpName = "okg:protocollo";
String path = OKMRepository.getInstance().getNodePath(null,uuid);
 
for (FormElement formElement : OKMPropertyGroup.getInstance().getProperties(null, path, grpName)) {
    if (formElement.getName().equals("okp:protocollo.registro")) {
        ((Input) formElement).setReadonly(false);
    }    
}
please help me
thanks a lot

Re: Disable an input form (property group element) for any user

PostPosted:Wed Sep 02, 2015 8:31 am
by jllort
This kind of feature is present on professional edition but still not in community version. You should do some changes in source code for it ( not trivial ), because the idea is set security in form element to disallow access on some users or roles ( is a dtd change, and also source code to take this changes in consideration )

Re: Disable an input form (property group element) for any user

PostPosted:Tue Sep 08, 2015 11:39 am
by intel74
thank you for your reply jllort,
if I understand, using the community version, the only way to allow the modification of some metadata to a user and other data to a different user is to use differents forms in a workflow...it's right?
I've to define a workflow with many step and states so, for example:
User1 upload a document, start workflow, and fill a form inserting some data.
Then i can use this inserted data to modify metadata document (from code using a transaction).
At this point, wordkflow goes is in another state and User2 is enabled to fill another form that I can use to set others metatada (from code using another transaction)
is right this reasoning?
thank you in advance

Re: Disable an input form (property group element) for any user

PostPosted:Wed Sep 09, 2015 6:47 pm
by jllort
Yes is a way for doing it. The solution to you problem is set property group as readonly ( really it will be readonly only from user interface but not internally and you can change without limitation from workflow but not from user interface).

Take a look at http://www.openkm.com/dtd/property-groups-2.5.dtd and see the readonly attribute:
Code: Select all
<!ATTLIST property-group
	label CDATA #REQUIRED
	name CDATA #REQUIRED
	visible (true | false) "true"
	readonly (true | false) "false"
>
You can set:
Code: Select all
<property-group label="Consulting" name="okg:consulting" readonly="true">
    <input label="Code" type="text" name="okp:consulting.code" />
    <textarea label="Comment" name="okp:consulting.comment" />
</property-group>