0

First SDK-based Document Action - Multiple isExecutable() executions?

I just adapted the sample code to build and configure a simple, proof-of-concept, SDK-based document action in one of our Sandbox Vaults. (Side note: the write-ups and sample code are super valuable and well-written!). I can get a document action to trigger and complete successfully. All I have it set up to do is to write a single line to the Debug Log.

When I run it, I see that the isExecutable() function runs more often than I expect. Keep in mind that I may not know what I'm doing just yet, so this could be the way it works, or it could be a self-inflicted problem. After looking at the info below, can someone let me know if this is expected?

Thanks,

Kevin

 

Here's the guts of my code.

public void execute(DocumentActionContext documentActionContext) {

LogService logService = ServiceLocator.locate((LogService.class));
logService.info("Running the method '{}' for action '{}'.", "execute()", "vsdk_docaction_firstkpo__c");
}

public boolean isExecutable(DocumentActionContext documentActionContext) {

LogService logService = ServiceLocator.locate((LogService.class));
logService.info("Running the method '{}' for action '{}'.", "isExecutable()", "vsdk_docaction_firstkpo__c");
return true;
}

I set up the debugger and added a breakpoint within each function. Here's the sequence I observe, with the debug logs pasted below.

1) Click the actions menu icon in Vault
2) BREAK: isExecutable() runs - this is checking to see what actions should be displayed in the menu as it renders
3) Click the action from the actions menu
4) BREAK: isExecutable() runs - Not sure why it would run now
5) BREAK: isExecutable() runs - Not sure why it would run now
6) BREAK: execute() runs - this is expected because I triggered the action in step 3

I see the same behavior whether I use the actions menu from a single doc (the Doc Info page) or from the actions menu for a doc listed in the Library next to other docs.

Here's the log written by step 2

2018-11-28 20:59:13,922 Documentaction.com.veeva.vault.custom.actions.KPOFirstDocumentUserAction INFO *****Start Execution:[com.veeva.vault.custom.actions.KPOFirstDocumentUserAction]*****
2018-11-28 20:59:16,971 Documentaction.com.veeva.vault.custom.actions.KPOFirstDocumentUserAction INFO Running the method 'isExecutable()' for action 'vsdk_docaction_firstkpo__c'.
2018-11-28 20:59:17,117 Documentaction.com.veeva.vault.custom.actions.KPOFirstDocumentUserAction INFO *****End Execution:[com.veeva.vault.custom.actions.KPOFirstDocumentUserAction]*****

Here's the single log written by steps 4, 5, and 6 together

2018-11-28 20:59:19,625 Documentaction.com.veeva.vault.custom.actions.KPOFirstDocumentUserAction INFO *****Start Execution:[com.veeva.vault.custom.actions.KPOFirstDocumentUserAction]*****
2018-11-28 20:59:22,218 Documentaction.com.veeva.vault.custom.actions.KPOFirstDocumentUserAction INFO Running the method 'isExecutable()' for action 'vsdk_docaction_firstkpo__c'.
2018-11-28 20:59:22,333 Documentaction.com.veeva.vault.custom.actions.KPOFirstDocumentUserAction INFO *****End Execution:[com.veeva.vault.custom.actions.KPOFirstDocumentUserAction]*****
2018-11-28 20:59:22,393 Documentaction.com.veeva.vault.custom.actions.KPOFirstDocumentUserAction INFO *****Start Execution:[com.veeva.vault.custom.actions.KPOFirstDocumentUserAction]*****
2018-11-28 20:59:26,142 Documentaction.com.veeva.vault.custom.actions.KPOFirstDocumentUserAction INFO Running the method 'isExecutable()' for action 'vsdk_docaction_firstkpo__c'.
2018-11-28 20:59:32,935 Documentaction.com.veeva.vault.custom.actions.KPOFirstDocumentUserAction INFO Running the method 'execute()' for action 'vsdk_docaction_firstkpo__c'.
2018-11-28 20:59:33,049 Documentaction.com.veeva.vault.custom.actions.KPOFirstDocumentUserAction INFO *****End Execution:[com.veeva.vault.custom.actions.KPOFirstDocumentUserAction]*****

 

 

2 comments

  • Avatar
    Adam McMillan

    Hey Kevin,

    I spoke to our dev team about this, and it seems to be expected behavior, because it gets called when the gear is clicked (to check to see if it should show up in the menu), and again when execute() gets called.

  • Avatar
    Kevin O'Brien

    Thanks for the clarification, Adam.

    Kevin

Please sign in to leave a comment.