Skip to main content
Insert Banner Message here.

Community

Search

Welcome to Community

Can vault SDK trigger a change object state?

Answered

Comments

5 comments

  • John Choo

    Hi James,

    No, it is not possible to change the state of a record through Java SDK. I've experienced the same issue. What is your scenario?

    Regards,

    John

    0
  • Richard Pater

    James,

     

    Yes, it is possible to change an object's state, but you cannot just directly update the state__v field.  You need to initiate a user action.  Check out the documentation for Package com.veeva.vault.sdk.api.job:

    https://repo.veevavault.com/javadoc/vault-sdk-api/19.3.0/docs/api/index.html

     

    Thanks,

     

    Rich

    0
  • James Huang

    Hi, Richard

    I am working on the object state change SDK, and tried the following code from Vault JDK documents: 

      

         //Get an instance of job for invoking user actions

         JobService jobService = ServiceLocator.locate(JobService.class);

         JobParameters jobParameters = jobService.newJobParameters("record_user_action__v");

         //Run job to invoke user action to change state

         jobParameters.setValue("user_action_name", "change_state_to_in_use_useraction__c");

         jobParameters.setValue("records", records);

         jobService.run(jobParameters);

     

    I have the following questions:

    1. Do I need to create a JDK user action as record action first and hand over to Vault JDK job service to execute or I can use Vault configured user action to complete the state change without JDK record action?

    In the above code, the 3 parameters referring to:

    1. record_user_action__v
    2. user_action_name   I am not sure where to find this parameter from Vault configuration and insert here. 
    3. change_state_to_in_use_useraction__c   Is this the state the user want to change to?
    1. If I don’t need to create JDK record action, how do I find the user action name in Vault configuration?
    2. It seem that the Vault API documents are outdated and I can not import Package com.veeva.vault.sdk.api.job, instead I have to import the following

                    com.veeva.vault.sdk.api.job.JobParameters;

    com.veeva.vault.sdk.api.job.JobService;

    I am not sure if I did something wrong.

     

    0
  • James Huang

    Hi, Rich

    I am getting really closer now. I have an user action with label Change State to Approved. As per the instruction from the Java DSK documentation, I constructed the user_action_name parameter as change_to_approved_in_use_useracton_c, I run the the program and it give me the following error message:

    "This Java SDK code error caused by: [Unknown User Action [approved_useraction__c] specified"

     

    Please advise how to correct this.

     

    Many thanks!

     

    James

    0
  • James Huang

    Rich and Choo.

    Just share  with you folks. I solved this issue. I was able to change the state of a records based on the user action as per Veeva SDK documentation. The early error is caused by user action name is too long and get truncated. When I shorten the user action name, it works fine.

     

    James

    0

Please sign in to leave a comment.

Powered by Zendesk