01-03-2017 01:14 AM
Hi,
I have a requirement where I have to hide a custom action specified in an addon that I am using in my code. The action is required for a rule but I want to hide the action from users in document library and document preview page. I have tried the below way to hide the action but so far I am not successful.
The action bean-id defined in the addon service-context.xml that I want to hide - ev-ocr-english
Below is what I am trying to do in share-config-custom.xml under {classpathRoot}/alfresco/web-extension
<alfresco-config>
<config evaluator="string-compare" condition="DocLibActions">
<actions>
<action id="ev-ocr-english">
<evaluator>evaluator.doclib.action.disableAction</evaluator>
</action>
</actions>
</config>
</alfresco-config>
The above does nothing but if add replace="true" in the config tag above all the actions in the document preview page are hidden.
Please suggest a way on how to hide the custom action.
Thanks
Hiten Rastogi.
03-16-2017 08:59 AM
Hello.
You simply have to create a custom evaluator that checks the property's value, something like this (into the share "-context.xml" file):
<bean id="evaluator.doclib.isEmAnaliseDestinatario" parent="evaluator.doclib.action.value">
<property name="accessor" value="node.properties.san:statusDocumentoExterno" />
<property name="comparator">
<bean class="org.alfresco.web.evaluator.StringEqualsComparator">
<property name="value" value="Em Análise Destinatário" />
</bean>
</property>
</bean>
And then, in the action config, you use it, like (in the share-config-custom.xml file):
<action id="destinatario-rejeitar" type="javascript" label="Rejeitar"
icon="document-reject">
<evaluator>evaluator.doclib.isEmAnaliseDestinatario</evaluator>
<param name="function">onActionSimpleRepoAction</param>
<param name="action">destinatario-rejeitar-action</param>
<param name="successMessage">Rejeitado</param>
<param name="failureMessage">Problema ao executar ação</param>
</action>
01-31-2017 01:22 PM
Hello.
Do you have the source code for this addon?
If you do, why not to simply comment the block where the action is defined?
If you do not have the source code, you can try to copy the full block from the Share's code and change only what you need.
02-03-2017 06:50 AM
Thanks for the input Douglas. This action was in a addon and I didn't have access to the source code. I did what you have mentioned in the last but somehow I was not able to hide the action.
02-15-2017 06:44 AM
Hey.
If you have the AMP files, then you can extract the share configuration files from it, as it is a zip file with a different extension.
Try that and let me know if it works.
03-16-2017 08:24 AM
Hi Douglas,
Sorry for the late reply.
I was able to successfully hide the action by extracting the share configuration file and commenting out the relevant action and then putting back file in the amp.
Now, I am confronted with almost similar situation. I have to override the simple workflow's Approve and Reject action, I want them to only appear when the document has some comments in it.
How can I now override the simple workflow's Approve and Reject action with bean id document-approve and document-reject resp. so that I can add my custom evaluator that check for the comments ??
I was thinking of three things.
Can you please help me out with this.
Thanks
Hiten Rastogi
03-16-2017 08:59 AM
Hello.
You simply have to create a custom evaluator that checks the property's value, something like this (into the share "-context.xml" file):
<bean id="evaluator.doclib.isEmAnaliseDestinatario" parent="evaluator.doclib.action.value">
<property name="accessor" value="node.properties.san:statusDocumentoExterno" />
<property name="comparator">
<bean class="org.alfresco.web.evaluator.StringEqualsComparator">
<property name="value" value="Em Análise Destinatário" />
</bean>
</property>
</bean>
And then, in the action config, you use it, like (in the share-config-custom.xml file):
<action id="destinatario-rejeitar" type="javascript" label="Rejeitar"
icon="document-reject">
<evaluator>evaluator.doclib.isEmAnaliseDestinatario</evaluator>
<param name="function">onActionSimpleRepoAction</param>
<param name="action">destinatario-rejeitar-action</param>
<param name="successMessage">Rejeitado</param>
<param name="failureMessage">Problema ao executar ação</param>
</action>
03-18-2017 06:31 AM
Thanks Douglas,
Your suggested way worked.
Explore our Alfresco products with the links below. Use labels to filter content by product module.