---
schema_version: "1"
id: d602df423ecab37fbfe575bb0efe54e918e7d7860dc77f080244eab6c2c82a10
title: Veeva Vault Connector 1.5 Examples
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/veevavault-connector/latest/veevavault-connector-examples.md
canonical_url: https://docs.mulesoft.com/veevavault-connector/latest/veevavault-connector-examples
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 924acee7d64e8dcdf4b1f8d0637ead7954f2d2d4895f1d7b0ded8ed4c230c07a
description: MuleSoft Documentation Site
release: "1.5"
latest: true
---
---
product: Veeva Vault Connector
version: 1.5
is-latest-version: true
---

# Veeva Vault Connector 1.5 Examples

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

The following examples show how to configure the connector in Anypoint Studio:

- [Create Documents in Veeva Vault](#create-documents-on-the-vault)

- [Retrieve Document Details](#retrieve-document-details)

- [Fetch Document or Object Data](#fetch-document-or-object-data)

- [Validate a Spark Message](#validate-a-spark-message)

- [Invoke the REST API to Create a Single Document](#invoke-rest-api)

## Create Documents in Veeva Vault

This example creates documents in bulk with document metadata fetched from an external source
(database). Before creating documents in Veeva Vault, the document files are uploaded using the
Veeva Vault FTP server. The documents' `created` status is inserted in the database.

The following screenshots show the Studio app flows for this example:

![Create Documents operation Mule flow](/mulesoft/current/en-us/veevavault-connector/latest/_images/veevavault-connector-create-documents-example.png)

![Upload Documents operation Mule flow](/mulesoft/current/en-us/veevavault-connector/latest/_images/veevavault-connector-upload-documents-example.png)

### Create the First Flow

1.  From the **Mule Palette** view, select **HTTP** and drag the **Listener** source to the canvas.

2.  Configure HTTP Listener for your environment.

3.  From the **Mule Palette** view, select **Database** and drag the **Select** operation to the
    canvas to fetch document metadata from the table.

4.  Configure Database Connector to use your connection credentials.

5.  In the SQL Query Text field, enter `>SELECT * FROM createdocuments`.

6.  From the **Mule Palette** view, select **Core** and drag the **Flow Reference** component to the
    canvas to reference the subflow `upload-files-on-vault-ftp-server`.

7.  From the **Mule Palette** view, select **Core** and drag the **For Each** scope to the canvas
    containing the following elements:

    1.  From the **Mule Palette** view, select **Core** and drag the **Transform Message** component
        to the canvas to transform document metadata into CSV format.

    2.  From the **Mule Palette** view, select **Veeva Vault** and drag the **Create Documents**
        operation to the canvas.

    3.  Enter the following values for the Veeva Vault connection:

        - **Username**

        - **Password**

        - **Vault URL**

        - **Vault version**

        - **Vault client ID**

    4.  From the **Mule Palette** view, select **Database** and drag the **Bulk insert** operation
        to the canvas to insert the document created status data into the database table.

8.  Configure Database Connector to use your connection credentials.

9.  From the **Mule Palette** view, select **Core** and drag the **Logger** component to the canvas
    to log information in the console or log file.

### Create the Second Flow

1.  From the **Mule Palette** view, select **Core** and drag the **Logger** component to the canvas
    to log information for this subflow.

2.  From the **Mule Palette** view, select **Core** and drag the **For Each** scope to the canvas
    containing the following elements:

    1.  From the **Mule Palette** view, select **Core** and drag the **Logger** component to the
        canvas.

    2.  From the **Mule Palette** view, select **FTPS** and drag the **Read** operation to the
        canvas .

    3.  From the **Mule Palette** view, select **Core** and drag the **Logger** component to the
        canvas.

    4.  From the **Mule Palette** view, select **FTPS** and drag the **Write** operation to the
        canvas to write the file to the Veeva Vault FTP server.

3.  From the **Mule Palette** view, select **Core** and drag another **Logger** component to the
    canvas.

4.  Configure FTPS Connector to use the credentials for the Veeva Vault FTP server.

### XML for the Example

Paste this code into your Studio XML editor to quickly load the two flows of this example into your
Mule app:

```xml
<flow name="create-documents-operationFlow" >
    <http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/create-documents"/>
    <db:select doc:name="Select" config-ref="Database_Config">
        <db:sql >SELECT * FROM createdocuments</db:sql>
    </db:select>
    <flow-ref doc:name="upload-files-on-vault-ftp-server" name="upload-files-on-vault-ftp-server"/>
    <ee:transform doc:name="Transform Message" >
        <ee:message>
            <ee:set-payload><![CDATA[%dw 2.0
output application/csv headerLineNumber = 0 , header = true
---
payload map ( payload01 , indexOfPayload01 ) -> {
	lifecycle__v: payload01.lifecycle__v,
	study__v: payload01.study__v,
	subtype__v: payload01.subtype__v,
	name__v: payload01.name__v ++ '--' ++ randomInt(10000) as String,
	type__v: payload01.type__v,
	classification__v: payload01.classification__v,
	product__v: payload01.product__v,
	file: payload01.file as String
	}]]></ee:set-payload>
        </ee:message>
    </ee:transform>
    <veevavault:create-documents metadataFormat="CSV" doc:name="Create Documents" config-ref="Veeva_Vault_Config"/>
    <db:bulk-insert doc:name=__"Bulk insert" config-ref="Database_Config">
        <db:bulk-input-parameters ><![CDATA[#[output application/java
---
payload.data map () -> {
	'id': $.id as String,
	'external_id__v': $.external_id__v as String,
	'responseStatus': $.responseStatus
	}]]]>
        </db:bulk-input-parameters>
        <db:sql >INSERT into documents (id, external_id__v, responseStatus) VALUES (:id: external_id__v, :responseStatus)
</db:sql>
    </db:bulk-insert>
    <logger level="INFO" doc:name="Logger" message="Document Created :: #[output application/json --- payload]"/>
    <error-handler >
        <on-error-propagate enableNotifications="true" logException="true" doc:name="On Error Propagate" type="ANY" >
            <logger level="INFO" doc:name="Logger" message="Flow Exception Handled --  #[payload]" />
        </on-error-propagate>
    </error-handler>
</flow>
```

## Retrieve Document Details

This example retrieves document details based on document type, subtype, and classification and then
stores the document details in the database.

The following screenshot shows the Studio app flow for this example:

![Get Documents operation Mule flow](/mulesoft/current/en-us/veevavault-connector/latest/_images/veevavault-connector-get-documents-example.png)

1.  From the **Mule Palette** view, select **HTTP** and drag the **Listener** source to the canvas.

2.  Configure HTTP Listener for your environment.

3.  From the **Mule Palette** view, select **Veeva Vault** and drag the **Get Documents** operation
    to the canvas.

4.  Enter the following values for the Veeva Vault connection:

    - **Username**

    - **Password**

    - **Vault URL**

    - **Vault version**

    - **Vault client ID**

5.  Click the respective refresh button to fetch the document type, subtype, and classification
    list.

6.  Select the document type, subtype, and classification from each of the respective drop-down
    lists.

7.  Add the document properties in the Document Properties list for your business requirements to
    incorporate the properties name in the VQL query to build dynamically.

8.  From the **Mule Palette** view, select **Core** and drag the **For Each** scope to the canvas
    containing the following elements:

    1.  From the **Mule Palette** view, select **Core** and drag the **Transform Message** component
        to the canvas.

    2.  From the **Mule Palette** view, select **Database** and drag the **Insert** operation to the
        canvas.

    3.  Configure the Database Connector configuration with your connection credentials.

9.  Using DataWeave, configure the transformation according to your business requirements.

10. Configure the **Insert** operation to insert data into table.

11. From the **Mule Palette** view, select **Core** and drag the **Set Payload** transformer to the
    canvas to set a payload to return to the triggered source.

12. From the **Mule Palette** view, select **Core** and drag the **Logger** component to the canvas
    to log information in the console or log file.

### XML for the Example

Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule
app:

```xml
<flow name="get-documents-operationFlow" >
	<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/get-documents" />
	<veevavault:get-documents doc:name="Get Documents" config-ref="Veeva_Vault_Config" >
		<veevavault:documents type="site_management__c">
		<veevavault:document-properties >
		<veevavault:document-property value=__"name__v"__ />
		<veevavault:document-property value=__"type__v"__ />
		<veevavault:document-property value=__"subtype__v"__ />
		<veevavault:document-property value=__"classification__v"__ />
		<veevavault:document-property value=__"lifecycle__v"__ />
		<veevavault:document-property value=__"status__v"__ />
		<veevavault:document-property value=__"study__v"__ />
		<veevavault:document-property value=__"product__v"__ />
		</veevavault:document-properties>
		</veevavault:documents>
	</veevavault:get-documents>
	<foreach doc:name="For Each" >
	<ee:transform doc:name="Transform Message" >
		<ee:message >
		<ee:set-payload ><![CDATA[%dw 2.0
		output application/json
		---
		payload]]></ee:set-payload>
		</ee:message>
	</ee:transform>
	<db:insert doc:name="Insert" config-ref="Database_Config">
		<db:sql >INSERT INTO [.underline]#createdocuments# (name__v, type__v, subtype__v, classification__v, lifecycle__v,
		product__v, status__v, study__v, file) VALUES (:name__v, :type__v, :subtype__v, :classification__v, :lifecycle__v, :product__v, :status__v, :study__v, :file)</db:sql>
		<db:input-parameters ><![CDATA[#[%dw 2.0
		output application/json
		---
		{
			'name__v': payload.name__v as String,
			'type__v': payload.type__v as String,
			'subtype__v': payload.subtype__v as String,
			'classification__v': payload.classification__v as String,
			'lifecycle__v': payload.lifecycle__v as String,
			'product__v': payload.product__v[0],
			'status__v': payload.status__v as String,
			'study__v': payload.study__v[0],
			'file': "CDA.docx"
		}]]]></db:input-parameters>
	</db:insert>
	</foreach>
	<set-payload value="#[output application/json --- payload.payload]" doc:name="Set Payload" />
	<logger level=__"INFO" doc:name="Logger" message="Document Details :: #[payload]"/>
	<error-handler >
	<on-error-propagate enableNotifications="true" logException="true" doc:name="Error Propagate" type="ANY" >
	<logger level="INFO" doc:name="Logger" message="Flow Exception Handled -- #[payload]" />
	</on-error-propagate>
	</error-handler>
	</flow>
```

## Fetch Document or Object Data

This example uses a VQL query to fetch document or object data from Veeva Vault.

The following screenshot shows the Studio app flow for this example:

![Query operation Mule flow](/mulesoft/current/en-us/veevavault-connector/latest/_images/veevavault-connector-query-example.png)

1.  From the **Mule Palette** view, select **HTTP** and drag the **Listener** source to the canvas.

2.  Configure HTTP Listener for your environment.

3.  From the **Mule Palette** view, select **Veeva Vault** and drag the **Query** operation to the
    canvas.

4.  Enter the following values for the Veeva Vault connection:

    - **Username**

    - **Password**

    - **Vault URL**

    - **Vault version**

    - **Vault client ID**

5.  Define the VQL query according to your business requirement.

6.  Add an input placeholder if used in the VQL query to incorporate dynamically with VQL at
    runtime.

7.  From the **Mule Palette** view, select **Core** and drag the **For Each** scope to the canvas
    containing the following elements:

    1.  From the **Mule Palette** view, select **Core** and drag the **Transform Message** component
        to the canvas.

    2.  From the **Mule Palette** view, select **File** and drag the **Write** operation to the
        canvas.

8.  Configure the transformation according to your business requirements using DataWeave.

9.  Configure the File Connector configuration with the working file path.

10. Configure the **Write** operation to write payload data into the specified file.

11. From the **Mule Palette** view, select **Core** and drag the **Set Payload** transformer to the
    canvas to set a payload to return to the triggered source.

12. From the **Mule Palette** view, select **Core** and drag the **Logger** component to the canvas
    to log information in the console or log file.

### XML for the Example

Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule
app:

```xml
<flow name="query-operation-with-database-operationFlow" >
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/query"/>
		<veevavault:query doc:name="Query" fetchSize="1000" config-ref="Veeva_Vault_Config">
			<veevavault:vql >SELECT id, name__v, type__v, subtype__v, classification__v, lifecycle__v, status__v, study__v, product__v  from :table WHERE name__v= 'F22611234--6764'</veevavault:vql>
			<veevavault:input-parameters ><![CDATA[#[{
				'table': 'documents'
			}]]]></veevavault:input-parameters>
		</veevavault:query>
		<foreach doc:name="For Each" >
		<ee:transform doc:name="Transform Message" >
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
				output application/json
				---
				payload]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<file:write doc:name="Write" path="query.json" config-ref="File_Config" mode="APPEND">
			<file:content><![CDATA[#[output application/json
			---
			payload]]]></file:content>
						</file:write>

		</foreach>
		<set-payload value="#['Flow Completed']" doc:name="Set Payload" />
		<logger level="INFO" doc:name="Logger" message="Query Operation flow Completed - #[payload]"/>
		<error-handler >
			<on-error-propagate enableNotifications="true" logException="true" doc:name="On Error Propagate" type="ANY">
				<logger level="INFO" doc:name="Logger" message="Flow Exception Handled --  #[payload]"/>
			</on-error-propagate>
		</error-handler>
	</flow>
```

## Validate a Spark Message

This example triggers a Spark message from Veeva Vault and validates the Spark message.

The following screenshot shows the Studio app flow for this example:

![Spark Validator operation Mule flow](/mulesoft/current/en-us/veevavault-connector/latest/_images/veevavault-connector-spark-validator-example.png)

1.  From the **Mule Palette** view, select **HTTP** and drag the **Listener** source to the canvas.

2.  The JKS certificate for HTTP Connector requires the `.jks` file for HTTP Listener to receive
    Spark messages over a TLS connection with Veeva Vault.  
    The following steps show how to create a `.jks` file using the Java Keytool located under the
    `<JDK_HOME>/bin` directory:

3.  Run the following command from the `<JDK_HOME>/bin` directory:

    \`keytool -genkey -keyalg RSA -alias mule -keystore spark-listener.jks -storepass password
    -validity 360 -keysize 2048\`

    This creates a \`spark-listener.jks\` file in the current directory.

4.  Copy and import the `spark-listener.jks` file from the `src/main/resources` project directory.

5.  Configure HTTP Listener as follows:

    1.  In the **General** tab, configure the following:

        - Protocol: HTTPS

        - Host: 0.0.0.0

        - Port: 8082

    2.  In the **TLS** tab, configure the following:

        - Type: JKS

        - Path: spark-listener.jks

        - Alias: mule

        - Key Password: password

        - Password: password

6.  From the **Mule Palette** view, select **Veeva Vault** and drag the **Spark Validator**
    operation to the canvas.

7.  Enter the following values for the Veeva Vault connection:

    - **Username**

    - **Password**

    - **Vault URL**

    - **Vault version**

    - **Vault client ID**

8.  Configure the **Spark Validator** parameters as follows:

    - Include Spark Header: `FALSE`

    - Public Key Path: `${file.keyPath}`  
      Define the `file.keyPath` property in the `configuration.yaml` with the path to where the
      public key file (00001.pem) is stored.

    - Spark Headers: `#[attributes.headers]`

    - Spark Message: `#[payload]`

9.  From the **Mule Palette** view, select **Core**, drag the **Set Payload** operation to the
    canvas, and define the following in the **Value** field:

    \---- output application/json --- { "payload" : payload, "attributes": attributes }
    ----

10. From the **Mule Palette** view, select **Core** and drag the **Logger** component to the canvas
    to log the payload with the following message:

    Spark Message :: #\[payload\]

### XML for the Example

Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule
app:

```xml
<flow name="spark-message-validator-operationFlow" >
    <http:listener doc:name="Listener" config-ref="Spark_Listener" path="/"/>
    <veevavault:spark-message-validator doc:name="Spark Validator" config-ref="Veeva_Vault_Config" publicKeyPath="${file.keyPath}" includeSparkHeader="TRUE"/>
    <set-payload value='#[output application/json --- {
			"payload" : payload,
			"attributes": attributes
		}]' doc:name="Set Payload" />
    <logger level="INFO" doc:name="Logger" message="Spark Message :: #[payload]"/>
</flow>
```

## Invoke the REST API to Create a Single Document

This example invokes the REST API to create a single document.

The following screenshot shows the Studio app flow for this example:

![Invoke REST API operation Mule flow](/mulesoft/current/en-us/veevavault-connector/latest/_images/veevavault-connector-invoke-rest-api-example.png)

> [!NOTE] You must configure the parameters according to your requirements to invoke the Veeva Vault
> REST API.

1.  From the **Mule Palette** view, select **HTTP** and drag the **Listener** source to the canvas.

2.  Configure HTTP Listener for your environment.

3.  From the **Mule Palette** view, select **File** and drag the **Read** operation to the canvas
    and configure the file path to read from the file content that is associated with Veeva Vault
    document.

4.  From the **Mule Palette** view, select **Veeva Vault** and drag the **Invoke REST API**
    operation to the canvas.

5.  Enter the following values for the Veeva Vault connection:

    - **Username**

    - **Password**

    - **Vault URL**

    - **Vault version**

    - **Vault client ID**

6.  Configure the POST request:

    Method: POST, Path: "/objects/documents", Headers: Key: "Accept" Value: "application/json" Key:
    "Content-Type" Value: "multipart/form-data; boundary=abcdefg" URI Parameters: Leave it empty.
    Query Parameters: Leave it empty.

    %dw 2.0 output multipart/form-data boundary='abcdefg'
    ---

    { parts: { file: { headers: { "Content-Disposition": { "name": "file", "filename":
    attributes.fileName }, "Content-Type": payload.^mimeType }, content : payload }, name\_\_v: {
    headers: {

        		},
        		content: 'Test Document'
        	},
        	type\_\_v: {
        		headers: {

        		},
        		content: 'Trial Management'
        	},
        	subtype\_\_v: {
        		headers: {

        		},
        		content: 'Meetings'
        	},
        	classification\_\_v: {
        		headers: {

        		},
        		content: 'Kick-off Meeting Material'
        	},
        	lifecycle\_\_v: {
        		headers: {

        		},
        		content: 'Base Doc Lifecycle'
        	},
        	study\_\_v: {
        		headers: {

        		},
        		content: '0ST000000000301'
        	},
        	comments\_\_c: {
        		headers: {

        		},
        		content: 'Test Document'
        	}
        }

    }

7.  Configure the PUT request:

    Method: PUT, Path: "/objects/documents/{doc\_id}", Headers: Key: "Accept" Value:
    "application/json" Key: "Content-Type" Value: "application/x-www-form-urlencoded" URI
    Parameters: Key: "doc\_id" Value: "259592" Query Parameters: Leave it empty.

    %dw 2.0 output application/x-www-form-urlencoded
    ---

    { "id": "259592", "name\_\_v": "Kick-off Meeting Material Updated", "product\_\_v":
    "00P000000000403", "study\_\_v": "0ST000000000202", "notes\_\_v": "Notes Updated" }

8.  From the **Mule Palette** view, select **Core** and drag the **Logger** component to the canvas
    to log the payload with the following message:

        Invoke Veeva API response :: #\[payload\]

### XML for the Example

Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule
app:

    <flow name="invoke-veeva-api-operationFlow" >
    	<http:listener doc:name="Listener" config-ref="HTTP\_Listener\_config" path="/invoke-veeva-api"/>
    	<file:read doc:name="Read" config-ref="File\_Config" path="#\['testdata/Test Document Renditions.pdf'\]" outputMimeType="application/octet-stream"/>
    	<veevavault:invoke-rest-api doc:name="Invoke REST API" config-ref="Veeva\_Vault\_Config" path="/objects/documents" method="POST">
    		<veevavault:body ><!\[CDATA\[#\[%dw 2.0

output multipart/form-data boundary='abcdefg'
---

{ parts: { file: { headers: { "Content-Disposition": { "name": "file", "filename":
attributes.fileName }, "Content-Type": payload.^mimeType }, content : payload }, name\_\_v: {
headers: {

    		},
    		content: 'Test Document'
    	},
    	type\_\_v: {
    		headers: {

    		},
    		content: 'Trial Management'
    	},
    	subtype\_\_v: {
    		headers: {

    		},
    		content: 'Meetings'
    	},
    	classification\_\_v: {
    		headers: {

    		},
    		content: 'Kick-off Meeting Material'
    	},
    	lifecycle\_\_v: {
    		headers: {

    		},
    		content: 'Base Doc Lifecycle'
    	},
    	study\_\_v: {
    		headers: {

    		},
    		content: '0ST000000000301'
    	},
    	comments\_\_c: {
    		headers: {

    		},
    		content: 'Test Document'
    	}
    }

}\]\]\]></veevavault:body> <veevavault:headers ><!\[CDATA\[#\[output application/java
---

{ "Accept" : "application/json", "Content-Type" : "multipart/form-data; boundary=abcdefg"
}\]\]\]></veevavault:headers> </veevavault:invoke-rest-api>
<logger level="INFO" doc:name="Logger" message="Invoke Veeva API response :: #\[payload\]" />
</flow>

## See Also

- [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors)

- [Salesforce Help](https://help.salesforce.com)
