0

cannot run debegger for Document Action Sample

Kevin,

I am traing to run the veeva/vsdk-document-sample, Create Related Records custom action, but it dosn't allow me to complete the operation if I run Debugger. I got the following error message.

'Server having problems

Duplicate key com.veeva.vault.custom.actions.CreateRecordsDocumentEntryAction"

However, I was able to run other ChangeFieldsDocumentUserAction task with debugger without any problem.

 

Please help

 

James

4 comments

  • Avatar
    Kevin N

    Hi James,

    This is actually caused by a bug in the SDK debugger that is addressed in 19R1. You should still be able to run the deployed code without the debugger.

    In the meantime, you can add LogService calls to output log messages to the Debug Logs and run the SDK actions without the debugger or modify the document lifecycle so that there is only one SDK action at a time on all states.

     

    Thanks,

    Kevin

     

  • Avatar
    James Huang

    Hi, Kevin,

    Is it possible to build entry criteria using SDK API? Since the Veeva entry critiria can not express or logic, for example, I want to the entry critiria to be that at least one related record state is either "approved", or "closed", The current entry critiria doesn't not allow you to express this. It only allows and operator. So I am thinking of SDK to define the entry critiria to express or operation.

     

    You have been very helpful!

    Can you advise?

     

    Thanks

     

    James

  • Avatar
    James Huang

    Hi, Kevin,

    Is it possible to build entry criteria using SDK API? Since the Veeva entry critiria can not express or logic, for example, I want to the entry critiria to be that at least one related record state is either "approved", or "closed", The current entry critiria doesn't not allow you to express this. It only allows and operator. So I am thinking of SDK to define the entry critiria to express or operation.

     

    You have been very helpful!

    Can you advise?

     

    Thanks

     

    James

  • Avatar
    Kevin N

    Hi James,

    The Vault Java SDK does not have the ability to create custom entry criteria.

    However, you can implement custom logic inside of a SDK entry action to do something similar. A custom entry action will allow you to query for related records:

    String queryString = "select relationship_type__v,target__vr.version_id,target_vr.status__v from relationships where source__vr.version_id = '" + version_id + "'";
    QueryResponse queryResponse = queryService.query(queryString);

    Then once you have the related records, only continue if the status is either "approved" or "closed". If it isn't one of those states, you then error out and throw a RollBackException to rollback the transaction (the entry action will fail and the document will return to the state it was in before the entry action ran):

    Iterator<QueryResult> queryResults = queryResponse.streamResults().iterator();

    while(queryResults.hasNext()) {
    QueryResult queryResult = queryResults.next();
    String status = queryResult.getValue("target_vr.status__v", ValueType.PICKLIST_VALUES).get(0)

    if (status.equals("Approved" || status.equals("Closed"){
    <do custom logic>
    }
    else {
    throw new RollbackException("OPERATION_NOT_ALLOWED", "No related document in the 'Approved' or 'Closed' state.");
    }
    }

    It should be noted that a RollBackException or other errors in a SDK entry action will generally only appear in the debug logs. The user would typically just see a generic "Server having issues" error message with the full error in the debug logs.

     

    Thanks,
    Kevin

Please sign in to leave a comment.