cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Action - Custom Failure/Success Message?

mtw999
Champ in-the-making
Champ in-the-making
Hi,

I have a custom action that works fine, but upon failure/success I want to display a message with some additional information that results from the execution of the ActionExecuter class. For example, ActionExecuter checks to see if 3 document types are present in a folder. If they are not present, I'd like to have a message:

"Could not complete MyAction:
"Document Type A is not in MyFooFolder"
"Document Type C is not in MyFooFolder"

The failure/success message is being provided as value in a properties file, but I'd like it to be more dynamic.

<action id="closed-submission" type="javascript" icon="closed-submission" label="actions.check-mystuff">
            <param name="function">onCheckMyStuffAction</param>
            <param name="action">check-mystuff</param>
            <param name="successMessage">message.check-mystuff.success</param>
            <param name="failureMessage">message.check-mystuff.failure</param>
            <permissions>
               <permission allow="true">Write</permission>
            </permissions>
            <evaluator>evaluator.fda.doclib.action.isMyStuffChecked</evaluator>
            </action>

(How) can I pass/define messages so that it has info I want it to have? Can I somehow redefine message.check-mystuff.success in my Action class?
2 REPLIES 2

niketapatel
Star Contributor
Star Contributor
Hi, Yes you can do this. Try below steps. I am giving generic scenario that you can apply in your case.

1)From Share UI, I click on custom action
2)This action will call your Repo data webscript to check datatype OR whatever is your logic.
3)You can define specific Success/Failure message as part of your data webscript's JSON response.
4)You can access this response and so this custom message in Share client side js
5)Display this message to users.

For Failure I would suggest You can add, specific template file with failure status code and Failure message.
Ex: customAction.get.json.500.ftl  , customAction.get.json.400.ftl etc..

Hope it helps!

mtw999
Champ in-the-making
Champ in-the-making
Not sure I understand what you are saying. So, are you saying I need to create a web script that is called from within (in my example below) from onMyNewAction function that does the datatype checks? I'm already doing these checks in the actionExecuter class but if the only way to get at the data from the js is from webscript response, then I guess i can do that. I need information about the node the action is being executed against (for that web script). Where is that exposed from within onMyNewAction js? In jsNode = record.jsNode;?

Honestly, it seems you should be able to pass information between ActionExecuter class and the interface.


&lt;action id="my-new-action" type="javascript" icon="my-new-action" label="actions.my-new-action" &gt;
&lt;param name="function"&lt;onMyNewAction&lt;/param&gt;
&lt;param name="action"&lt;my-new-action&lt;/param&gt;
&lt;param name="successMessage"&lt;message.my-new-action.success&lt;/param&gt;
&lt;param name="failureMessage"&lt;message.my-new-action.failure&lt;/param&gt;
&lt;permissions&gt;
&lt;permission allow="true">Write&lt;/permission&gt;
&lt;/permissions&gt;
&lt;/action&gt;