# Retrieve value of business object use Bonita Engine API

**URL:** <https://community.ofelia.com/t/retrieve-value-of-business-object-use-bonita-engine-api/9505>\
**Category:** Q&A\
**Created:** [8 March 2019 07:28 UTC](https://community.ofelia.com/t/retrieve-value-of-business-object-use-bonita-engine-api/9505 "2019-03-08T07:28:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nampham97se\_1390962](https://avatars.discourse-cdn.com/v4/letter/n/f6c823/32.png) [@nampham97se\_1390962](https://community.ofelia.com/u/nampham97se_1390962)\
**Post date:** [8 March 2019 07:28 UTC](https://community.ofelia.com/t/retrieve-value-of-business-object-use-bonita-engine-api/9505/1 "2019-03-08T07:28:33Z")

</div>

Hello, i'm new Bonita, i have a case need idea for project Spring boot retrieve value on business object.

The first, i seen that how can get value of business object with add file jar entitis and DAO in link :

http://community.ofelia.com/questions-and-answers/access-business-data-object-using-java-api-v-714

And it work good. But this way is very&nbsp;dependencies file jar export from Bonita&nbsp;and just static attribute for external project.

So when i need change (add, modify) business data object, i must reset bdm and build again to project, it not real for release.

Anyone have idea retrieve value of business object use Java API not dependency 2 file jar DAO and entity?.

Thanks.

---

<div class="post-metadata">

**Author:** ![rtumminelli\_1394599](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/rtumminelli_1394599/32/1412_2.png) [@rtumminelli\_1394599](https://community.ofelia.com/u/rtumminelli_1394599)\
**Post date:** [14 March 2019 18:21 UTC](https://community.ofelia.com/t/retrieve-value-of-business-object-use-bonita-engine-api/9505/2 "2019-03-14T18:21:26Z")

</div>

The **subscription** version of Bonita lets you add **up to 5** &nbsp;"Search Keys" to a process, allowing one to attribute **String&nbsp;** data to your process instances.&nbsp;You can then access through the API like so:&nbsp;

processInstance.getStringIndex1()

&nbsp;

Not sure if this is the intended use for Search Keys, and if you need access to the entire BDM object, non-String data, or&nbsp;more than 5 fields this won't work for you. In my project, each process has 1 BDM object associated with it. When I start a process, I set the value of it's StringIndex1 to the ID of my BDM object, so later I can easily find process instances by my BDM object ID's.&nbsp;

&nbsp;

Ultimately, I think the correct way to access BDM data in your Java application requires you to rely on the exported dependencies from Bonita like you found. Seeing as modifying the BDM in any way completely resets it, it seems like one shouldn't really be doing it often.

---

<div class="post-metadata">

**Author:** ![nampham97se\_1390962](https://avatars.discourse-cdn.com/v4/letter/n/f6c823/32.png) [@nampham97se\_1390962](https://community.ofelia.com/u/nampham97se_1390962)\
**Post date:** [15 March 2019 01:51 UTC](https://community.ofelia.com/t/retrieve-value-of-business-object-use-bonita-engine-api/9505/3 "2019-03-15T01:51:36Z")

</div>

Thank you very much for answer,

I will find other&nbsp;solution with rest api or customize it and currently, I use Community version&nbsp;:)

Can you give your contract like email or facebook, i want to direct message for support faster about problems?

And now is Bonita not suport for retrieve value in archived case? I have easy retrieved business object from open case but when it case complete, i seen fail with error:Not found reference Business name&nbsp;"xx" with&nbsp;processInstanceId "yy" althought i put direct caseId and like function of open case(true function) . That very sad when client who want to see detail a task done in my Spring boot UI. Can you have idea for it?

Thanks.

---

<div class="post-metadata">

**Author:** ![rtumminelli\_1394599](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/rtumminelli_1394599/32/1412_2.png) [@rtumminelli\_1394599](https://community.ofelia.com/u/rtumminelli_1394599)\
**Post date:** [15 March 2019 15:23 UTC](https://community.ofelia.com/t/retrieve-value-of-business-object-use-bonita-engine-api/9505/4 "2019-03-15T15:23:01Z")

</div>

How are you currently getting business objects from open cases? Are you doing something like this?

```
ProcessAPI processAPI = TenantAPIAccessor.getProcessAPI(session);

Map<String, Serializable> context = processAPI.getProcessInstanceExecutionContext(processInstanceId);

SimpleBusinessDataReferenceImpl objectRef = (SimpleBusinessDataReferenceImpl) context.get("object_ref");

BusinessObjectDAOFactory daoFactory = new BusinessObjectDAOFactory();

ObjectDAO objectDao = daoFactory.createDAO(session, ObjectDAO.class);

Object object = objectDao.findByPersistenceId(objectRef.getStorageId());
```

(Where object is your business object).

getProcessInstanceExecutionContext is used for active processes, and **getArchivedProcessInstanceExecutionContext** is used for archived processes (and must be provided an **archivedProcessInstanceId** ). From the ArchivedProcessInstanceContext, you should be able to get your business object.

---

<div class="post-metadata">

**Author:** ![nampham97se\_1390962](https://avatars.discourse-cdn.com/v4/letter/n/f6c823/32.png) [@nampham97se\_1390962](https://community.ofelia.com/u/nampham97se_1390962)\
**Post date:** [15 March 2019 15:59 UTC](https://community.ofelia.com/t/retrieve-value-of-business-object-use-bonita-engine-api/9505/5 "2019-03-15T15:59:21Z")

</div>

Thanks for answer,

[archivedProcessInstanceId](https://drive.google.com/open?id=19h-XH-uio3OphajfpjhSpR3KrWAdw9-h)&nbsp;This image is that right&nbsp;archivedProcessInstanceId&nbsp;you mean?

I have create two function with your example code. And i just fine with active task ([This image test success Active task](https://drive.google.com/open?id=1dWRLYuRvlxnCNihBwTMnn5n2AneZlt4c)). But with archived task, i alway get error like&nbsp;this&nbsp;[Image error archived task](https://drive.google.com/open?id=1X7JKaSqEiP52jXNwdX2wyTKOWu_iNMQM). I have try other way, search archived process -\> get BDM. But still fail with [error other way](https://drive.google.com/open?id=1j_4AUUbjzyyAMkXkz0pCAfrSVJn9jSSO).

Is you have try get business object with archived?. Can you give your&nbsp;contract info&nbsp;like email or fb, twiter, etc&nbsp;for support,&nbsp;I will be very grateful :).

---

<div class="post-metadata">

**Author:** ![rtumminelli\_1394599](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/rtumminelli_1394599/32/1412_2.png) [@rtumminelli\_1394599](https://community.ofelia.com/u/rtumminelli_1394599)\
**Post date:** [15 March 2019 17:09 UTC](https://community.ofelia.com/t/retrieve-value-of-business-object-use-bonita-engine-api/9505/6 "2019-03-15T17:09:01Z")

</div>

Yes, that is a little misleading. The ID you see in the portal (41002) is **not** the archivedProcessInstanceId. An archived process has a rootprocessinstanceid&nbsp;(41002), and a separate Archive ID. I think you will have to use&nbsp;[getArchivedProcessInstances](https://documentation.bonitasoft.com/javadoc/api/7.8/org/bonitasoft/engine/api/ProcessRuntimeAPI.html#getArchivedProcessInstances-long-int-int-),&nbsp;which will return a List of ArchivedProcessInstance.

Something like:

```
getArchivedProcessInstances(41002L, 0, 100);
```

Maybe then iterate through that list and do&nbsp;getArchivedProcessInstanceExecutionContext(ArchivedProcessInstance.getId()) for each.

---

<div class="post-metadata">

**Author:** ![nampham97se\_1390962](https://avatars.discourse-cdn.com/v4/letter/n/f6c823/32.png) [@nampham97se\_1390962](https://community.ofelia.com/u/nampham97se_1390962)\
**Post date:** [20 March 2019 02:29 UTC](https://community.ofelia.com/t/retrieve-value-of-business-object-use-bonita-engine-api/9505/7 "2019-03-20T02:29:02Z")

</div>

Hello, today i tried example List getArchivedProcessInstaces, it give empty list but in portal i have task archived (41002). So currently i’m still choke with retrieve value in archived process mean find archived process. Any idea for solution will be help me more.  
Thanks.
