0

SDK Document UI-based user actions - Prompt for user input

I'm learning on the fly, so thanks for fielding this second of likely many how-to questions about the SDK. I'm honestly not sure that what I'm about to ask is supported today.

Here's the use case I'm considering: Custom Atomic Security on Document Lifecycle User Actions

  • To display, a user action must meet at least one of the following criteria
  1. Only allow members of a document's role(s) to execute the action
  2. Only allow members of a group to execute the action (Note: the user/group doesn't need to be explicitly named in a role.  For example: we may have a group called "Legal" who has a security profile that allows them to see all documents independent of the Sharing Settings.)
  3. Only allow members of a security profile to execute the action (Similar scenario to #2 but using a different way to identify an authorized user)
  • If authorized, ask for the normal WF start step inputs and initiate a document workflow

Desired behavior:
Ideally, I'd simply be able to use the isExecutable method to run my validation logic, but the menu click (the execute method) would just fire up the workflow start dialog of an existing document workflow. That avoids me having to replicate a workflow start step. Is that possible?  I don't think so.

Workaround behavior:
If I can't initiate the existing workflow start step, I see that Document Actions support the following:

https://developer.veevavault.com/sdk/#implementing-document-actions

  • user_input_object_type: If your action takes user input, you may want to identify the user input object type. If omitted, this action does not require a type for user input. Actions which require user input may not require a type.
  • user_input_object: If your action takes user input, identify the user input object. If omitted, this action does not require user input.

Does this imply that I can create a user action on a document lifecycle state that pops up an object data entry dialog? And does the action fire upon the save event of that dialog? Or am I making up a scenario that's not supported.

Thanks again for the insight.

Kevin

3 comments

  • Avatar
    Kevin N

    Hi Kevin,

    The desired behavior isn't fully possible. You can run the validation logic with the DocumentRoleService to check the roles of users and groups; however, the Vault Java SDK isn't currently able to start up a workflow or change the state of a document directly. This functionality is on the roadmap.

    Your workaround understanding is correct. You can define a "user_input_object" on the custom user action that will cause a input prompt to display when that action is called. When that input prompt is saved, an object record for the defined object is created (you can even run triggers on the insert) and then the results of the insert are accessible from within the action.

    See below for sample code:

    @DocumentActionInfo(label="Run 18R3 User Action Prompt Demo", user_input_object="vsdk_user_input_object__c", user_input_object_type="")
    public class DocumentUserActionPrompt18R3 implements DocumentAction {

    public void execute(DocumentActionContext documentActionContext) {

    DocumentService docService = ServiceLocator.locate((DocumentService.class));

    //New getUserInputRecord() method to retrieve the input record data.
    Record inputRecord = documentActionContext.getUserInputRecord();
    List<DocumentVersion> documentList = documentActionContext.getDocumentVersions();

    for (DocumentVersion actionRecord : documentList) {
    String comments = inputRecord.getValue("comments__c", ValueType.STRING);
    actionRecord.setValue("title__v", comments);
    }

    docService.saveDocumentVersions(documentList);
    }

    public boolean isExecutable(DocumentActionContext documentActionContext) {
    return true;
    }
    }

     

    Thanks,

    Kevin

  • Avatar
    Kevin O'Brien

    Thanks for the info and the example, Kevin.  This is exactly what I need to try it out.  I'll give it a try and will continue to annoy you guys with questions and I push the limits of my knowledge and the product's functionality.

    In terms of the roadmap item to allow us to launch an existing workflow... any ballpark estimate on that one?  If that's still up in the air, that's OK.  Just curious if that's a known, short-term thing or not.

    Kevin

  • Avatar
    Kevin O'Brien

    To close the loop on the user input prompt.. worked like a charm!  I was able to pop up the object record creation dialog, take the user input, and save it into the document's title.  Thanks again for that help.  I'll work through a few use cases we're looking at here at Zoetis and will see how we can apply this.

    Kevin

Please sign in to leave a comment.