# Instantiate a Business Variable from an Operation

**URL:** <https://community.ofelia.com/t/instantiate-a-business-variable-from-an-operation/6266>\
**Category:** Q&A\
**Created:** [6 August 2015 18:38 UTC](https://community.ofelia.com/t/instantiate-a-business-variable-from-an-operation/6266 "2015-08-06T18:38:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmickelson](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@dmickelson](https://community.ofelia.com/u/dmickelson)\
**Post date:** [6 August 2015 18:38 UTC](https://community.ofelia.com/t/instantiate-a-business-variable-from-an-operation/6266/1 "2015-08-06T18:38:12Z")

</div>

I am trying to do a simple Business Object\*\* Instantiate With\*\* from a service task as a test.

This is the Script Im using create a new ErrorDetail object and return it back to the business variable.

`
import com.company.model.ErrorDetail;
ErrorDetail newDetail = new com.company.model.ErrorDetail();
newDetail.setAcid(1234);
newDetail.setTmsecid(22)
newDetail.setTmcode(“tmcode”)
newDetail.setTimestmp(new Date());
newDetail.setErrorseverity(4);
newDetail.setErrormsg(“hello”)
newDetail.setSource(“source”)
newDetail.setBpstatus(0);
return newDetail;
`

I get a hibernate error.

Is it actually possible to do this? I know you can set the default value and also set attributes from Contracts, but can you instantiate a new BO from within a script?

Has anyone gotten this to work in V7?

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/community_bonitasoft/original/2X/6/6b7b18c0478f2645369e82e009b65e3b97f2cc12.svg) [@system](https://community.ofelia.com/u/system)\
**Post date:** [11 August 2015 08:14 UTC](https://community.ofelia.com/t/instantiate-a-business-variable-from-an-operation/6266/2 "2015-08-11T08:14:37Z")

</div>

Hi,

yes, you can.  
You should prefer to use ErrorDetailDAO.newInstance() instead of using the emptyu constructor.

Which error do you have?  
Are you sure that you don’t forget to set a mandatory field?  
Are you sure that there isn’t a “complex” atttributes?

Regards,
