# MRV Document Operations

For a demo example of following steps, here is the policy timestamp: **1675164736.675731674**

## **Task Summary**

There are two roles: ‘**User*****’*** and ***‘*****Approver*****’***. *User* can create projects and send project definition documents to the selected *Approvers*. After the approval, *User* can add MRV reports to the project. On the basis of this documents the policy will be minting tokens into the account configured in the project.

## **Preparation**

1. Create 2 roles ‘**User*****’*** and ‘**Approver*****’*** and the corresponding containers

(See [example 1](https://guardian.hedera.com/guardian/standard-registry/policies/library-of-policy-examples/creating-and-using-roles) for the more detailed description of how to work with roles)

![Creating 2 roles](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-49de6f12e80d883cabb2e389f3fb1377773f56cd%2F0%20\(4\).png?alt=media)

2. Create all needed document schemas:

2.1 Schema for ‘**User*****’*** containing the fields: **First name**, **Last name**

2.2 Schema for ‘**Approver*****’*** containing the fields: **First name**, **Last name**

2.3 Schema for ’**Project**’ containing the fields: **Project name**, **Account ID**

In order to mint tokens into another account (not into the account of the minting user) setup the required field

![Setting up new account](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-18283aeb35e8a268d3a96dfa0111d431e90f472e%2F1%20\(8\).png?alt=media)

2.4 Schema for ’**Report**’ containing the following fields: **Start Date, End Date, Amount**

(Please see [example 2](https://guardian.hedera.com/guardian/standard-registry/policies/library-of-policy-examples/data-input-via-forms-using-roles-to-partition-user-activities.) *for the more detailed description of how to work with Documents*)

3. Add blocks for registering ‘**User*****’*** and ‘**Approver*****’*** into the containers created in the step 1

**Note:** it is important that DID of the user is used for ID of the documents as this value will be used further in the document for filtration

![Adding DID as ID Type](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-87a8256531fbb5958bda3749c8fd98c61d66d36b%2F2%20\(3\)%20\(2\).png?alt=media)

4. Add simplified grids for displaying Projects, Reports and Tokens

![Adding grids](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-15f0920f22813a131ba9b363d34ee3985e4d2086%2F3%20\(2\)%20\(1\).png?alt=media)

5. Create the token

![image5.png](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-39080d4bbae5c0a28376a5245a55e9c2a6bec06a%2F4%20\(2\).png?alt=media)

## **Document Operations**

### 1. Project Definition

#### 1.1 Create a project

![Creating project](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-01abf4b8df66670fc080ad669cd71e3eccf34673%2F5%20\(1\)%20\(2\).png?alt=media)

### 1.2 Save the project

![Saving Project](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-bde37b51e7ffe236196397cd51e1ceda1f8503c6%2F6%20\(1\)%20\(2\).png?alt=media)

### 1.3 Link to the token

1.3.1 Since another (not current user) account is used for minted tokens ’**tokenActionBlock**’ cannot be used, instead we will use ‘**tokenConfirmationBlock*****’***

![Adding tokenConfirmationBlock](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-ac217cd26a8e07b3122a1738891cc742a111e837%2F7%20\(3\).png?alt=media)

1.3.2 To configure the target account for mixed tokens select ‘*Custom*’ value for ‘*Type*’ and the filed in the document from which to take the value for the Account ID (this field must have type: ‘**Account**’)

![Selecting Account Type and Id](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-015a6269ae72ca4b8e5c7b8c245dfce48ca9c2b0%2F8%20\(3\).png?alt=media)

1.3.3 By default ’**tokenConfirmationBlock**’ does not have a link to the next block, thus it needs to be manually added

![Manually adding tokenConfirmationBlock to next Block](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-962974b8fdb0745e0426fccb24e8e2552f9493a5%2F9%20\(2\).png?alt=media)

1.4 Add an approver as after the creation the project is not assigned to anyone

1.4.1 Add ’**interfaceActionBlock**’ wrapped into a container.

![Adding interfaceActionBlock](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-a03aaa1d50535113897d173c20ef2a34b539db27%2F10%20\(2\).png?alt=media)

1.4.2 Select **Dropdown** *value* *for* **Type**

![Selecting Dropdown value](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-6dd8132be55b6abb1250a4237aa8f47a838f18a1%2F11%20\(3\).png?alt=media)

1.4.3 Use system field **assignedTo** to filter documents based on users they are assigned to.

Record value from **assignedTo** *into* **Field** (This field will be changing our block)

![Using system Field assignedTo](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-cd184605aa44b7d1781a9a3db977007205a4699b%2F12%20\(3\)%20\(1\).png?alt=media)

1.4.4 Configure values from which fields from the document would be labels, and which ones would be values

![Configuring labels and values](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-a5c493058d63be9f239f7e743bff39437d434c5d%2F13%20\(2\).png?alt=media)

1.4.5 Use ‘**documentsSourceAddon**’ for data for **Dropdown*****.***

![adding documentSourceAddon](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-f6ea14710db906c18229ee1fc8280632c92e7161%2F14%20\(2\).png?alt=media)

1.4.6 Save the changed document

![Saving the documents](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-5e63d70607673c0dd170ffab312e1f8485a48878%2F15%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\).png?alt=media)

1.4.7 As ‘**documentsSourceAddon**’ does not have default events, we need manually add them.

![Adding events](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-879ada5ec2db6d86c157a6190115df462106944d%2F16%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\).png?alt=media)

1.4.8 Return to grid settings and add **Dropdown** into the target column.

![Adding Dropdown to target column](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-d41082f335b2fabb33040a7648e105b193f41487%2F17%20\(1\)%20\(2\).png?alt=media)

1.5 Project Approval. Setting up the grid for project approvals.

1.5.1 To select only the projects assigned to the current Approver set the ‘**Assigned to User**’ flag

![Setting up Assigned to User flag](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-449698c7f57b9d0aafe9162d4b4a8e13e038c0f0%2F18%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\).png?alt=media)

1.5.2 Add document approval block

*(Please see* [*example 2*](https://guardian.hedera.com/guardian/standard-registry/policies/library-of-policy-examples/data-input-via-forms-using-roles-to-partition-user-activities.) *for the more detailed description of this workflow)*

![Adding document approval block](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-7c583e2cf7fe7d6201d07450175dde57d98338fb%2F19%20\(2\).png?alt=media)

1.5.3 Add Approve button into the grid

![Adding Approve button to the grid](https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-bef966dff836bd6bc9bf139b5e6a396aad3a16fb%2F20%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\).png?alt=media)

1.5.4 After the Approve, setup the KYC for the account connected to the project

Use ‘**tokenActionBlock**’ with the appropriate settings

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-c339f3405ee484e4a88d5576f500623585f9526e%2FTemplate_4_screenshot_22.png?alt=media" alt=""><figcaption></figcaption></figure>

1.5.5 Configure the signing/verification of the document with the Approver signature by adding ‘**reassigningBlock**’. This block creates a copy of the source document and re-signs it with the key of the selected user.

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-f172e645eab30ed1958d99c0e86e4b0bc97704f6%2FTemplate_4_screenshot_23.png?alt=media" alt=""><figcaption></figcaption></figure>

1.5.6 Add Status attribute for easy filtering

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-e31c8cee35c473c6bd11bd1b6a3154a4422ecd15%2FTemplate_4_screenshot_24.png?alt=media" alt=""><figcaption></figcaption></figure>

### 2. Report.

To enable report creation only for approved projects, add create button into the grid selectively for documents with ‘Approved’ status

2.1 Add a ‘**documentsSourceAddon**' block to differentiate the documents on the basis of their status

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-acf3980356d05a2e94f9f812f38e33a2cb281b74%2FTemplate_4_screenshot_25.png?alt=media" alt=""><figcaption></figcaption></figure>

2.2 Repeat the sequence for project creation to create the report

{% hint style="info" %}
**Note:** switch off ‘**Default Active**’ since create report button does not need to be an independent object
{% endhint %}

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-d15c47ed0a31938b99611b8e247f3127e0ec970e%2FTemplate_4_screenshot_26.png?alt=media" alt=""><figcaption></figcaption></figure>

2.3 Add the button for creating reports into the grid

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-f8f2b3e34f3da26597415832deeb39d1c1d121d9%2FTemplate_4_screenshot_27.png?alt=media" alt=""><figcaption></figcaption></figure>

2.4 Use ‘**mintDocumentBlock**’ for creating (minting) tokens

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-a08e038650304858b742dcbe4957d2fb0c1a7524%2FTemplate_4_screenshot_28.png?alt=media" alt=""><figcaption></figcaption></figure>

### 3. Results

#### 3.1 Reports

3.1.1 Add grid to display reports

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-df0009b49d88a4f9be65ca84a930b702fc6e1b0c%2FTemplate_4_screenshot_29.png?alt=media&#x26;token=5e3c8e29-ab66-47a8-9445-7d470a20c397" alt=""><figcaption></figcaption></figure>

3.1.2 To filter reports on the basis of their project add dynamic filter ‘**filtersAddon**’

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-0ca3e75b2688d47ab76f9048444039f831237e1b%2FTemplate_4_screenshot_30.png?alt=media" alt=""><figcaption><p>Adding FiltersAddon</p></figcaption></figure>

3.1.3 Documents created on the basis of other documents are automatically linked via the ***ref*** field. Use it for filtration

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-6ad199bb56dea13ba866edffbb5b3034acd44a70%2FTemplate_4_screenshot_31.png?alt=media" alt=""><figcaption></figcaption></figure>

3.1.4 Add the data source for the filter which will display all approved projects of the current user

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-8792b6bc27fe57a04680e2fc9db71add36dc8d9e%2FTemplate_4_screenshot_32.png?alt=media" alt=""><figcaption></figcaption></figure>

3.1.5 Add display of all minted tokens

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-92312a513bc6ca98e9f9c05c0250c52abd180fa8%2FTemplate_4_screenshot_33.png?alt=media" alt=""><figcaption></figcaption></figure>

### **Demo**

#### Choose a role

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-8bfd78b654441aa8c97402a580580d58561ea096%2FTemplate_4_demot_01.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Create Approver

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-e1c0e88664567b5fe43088a1fda25e7e770b6335%2FTemplate_4_demot_02.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Create User

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-81d0bb0c7e1ce4dca94a240c4c5373567cbbf9cf%2FTemplate_4_demot_03.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Create Project

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-f572c11a77a9455ba221e9705a7145b6055812f2%2FTemplate_4_demot_04.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Associate token

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-032ede077be1e13c1971e11c84dafa53c1fb6fcd%2FTemplate_4_demot_05.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Choose an approver

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-7f9d2f704a04ef52028d84a2a8f2bfc29ef5be6c%2FTemplate_4_demot_06.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Approve project

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-b778ac6f5e267414c0151d2990bc37c8e7feb504%2FTemplate_4_demot_07.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-c33c9ce50b1f7a60425f130c7e722a51d352b549%2FTemplate_4_demot_08.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Create report

<figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-04a908ec774b07e1f2b0378581b0982a96b6845a%2FTemplate_4_demot_09.png?alt=media" alt=""><figcaption></figcaption></figure>

<div><figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-ca47224c10b3415f41f2b9b71bc921d358de154d%2FTemplate_4_demot_10.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://1556785885-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNYWPEEAknX9Vki1yV5HY%2Fuploads%2Fgit-blob-bd5af8fe29bb87c6e96eeca15532bc3db4fd1cf1%2FTemplate_4_demot_11.png?alt=media" alt=""><figcaption></figcaption></figure></div>
