# Form Mapping API

**URL:** <https://community.ofelia.com/t/form-mapping-api/10203>\
**Category:** Q&A\
**Created:** [1 June 2020 22:49 UTC](https://community.ofelia.com/t/form-mapping-api/10203 "2020-06-01T22:49:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pierre-yves\_Monnet](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@Pierre-yves\_Monnet](https://community.ofelia.com/u/Pierre-yves_Monnet)\
**Post date:** [1 June 2020 22:49 UTC](https://community.ofelia.com/t/form-mapping-api/10203/1 "2020-06-01T22:49:20Z")

</div>

Hello,

It will be super to have more explanation in the Bonita API.

I search to clone a process to a new one. i'm looking to clone the form Mapping;

1/ How to process the current list of form?

I believe this is :

SearchOptionsBuilder search &nbsp;= new SearchOptionsBuilder(0,100);  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; search.filter(FormMappingSearchDescriptor.PROCESS\_DEFINITION\_ID, processDesign.processDefinitionId);  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SearchResult\<FormMapping\> searchFormMapping = processAPI.searchFormMappings(search.done());  
&nbsp;

Then we can loop on the form Mapping

&nbsp; &nbsp; &nbsp; &nbsp;for (FormMapping formMapping : searchFormMapping.getResult()) {

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Page page = pageAPI.getPage(formMapping.getPageId());  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (page!=null)  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; formMappingBuilder.addTaskForm(page.getName(), formMapping.getTarget(), formMapping.getTask()); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}

Q1.1 Is that correct?

&nbsp;

2/ How can I build the new form ?

BusinessArchiveBuilder barBuilder = new BusinessArchiveBuilder().createNewBusinessArchive()  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setProcessDefinition(newDesign);  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FormMappingModelBuilder formMappingBuilder = FormMappingModelBuilder.buildFormMappingModel();  
&nbsp; for (FormMapping formMapping : searchFormMapping.getResult()) {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Page page = pageAPI.getPage(formMapping.getPageId());  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (page!=null)  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (formMapping.getType() == FormMappingType.PROCESS\_START)  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; formMappingBuilder.addProcessStartForm(page.getName(), formMapping.getTarget());  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (formMapping.getType() == FormMappingType.PROCESS\_OVERVIEW)  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; formMappingBuilder.addProcessOverviewForm(page.getName(), formMapping.getTarget());  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; formMappingBuilder.addTaskForm(page.getName(), formMapping.getTarget(), formMapping.getTask());  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }

&nbsp;

Q2.1 : how do I deploy this newFormMappingModel ?&nbsp;

&nbsp;

&nbsp; BusinessArchiveBuilder businessArchiveBuilder = new BusinessArchiveBuilder().createNewBusinessArchive();  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (artifactBuilder.processDefinitionBuilder != null)  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; businessArchiveBuilder.setProcessDefinition(artifactBuilder.processDefinitionBuilder.done());  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (artifactBuilder.formMappingBuilder != null) {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; businessArchiveBuilder.setFormMappings(artifactBuilder.formMappingBuilder.build());  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (artifactBuilder.actorMapping != null)  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; businessArchiveBuilder.setActorMapping(artifactBuilder.actorMapping);  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newDesign = artifactBuilder.processDefinitionBuilder.done();

&nbsp; &nbsp;Correct ?&nbsp;

At the end, my new process does not have any form mapping... Worst, it say "&nbsp;No form expected" for each tasks.

&nbsp;

Thank you,

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![nicolas.chabanoles](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/nicolas.chabanoles/32/721_2.png) [@nicolas.chabanoles](https://community.ofelia.com/u/nicolas.chabanoles)\
**Post date:** [30 October 2020 13:00 UTC](https://community.ofelia.com/t/form-mapping-api/10203/2 "2020-10-30T13:00:04Z")

</div>

Hi,

Sorry, the product does not offer the capacity you are looking for.

Captain Bonita

---

<div class="post-metadata">

**Author:** ![Pierre-yves\_Monnet](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@Pierre-yves\_Monnet](https://community.ofelia.com/u/Pierre-yves_Monnet)\
**Post date:** [1 June 2020 23:04 UTC](https://community.ofelia.com/t/form-mapping-api/10203/3 "2020-06-01T23:04:46Z")

</div>

Nb: the formMapping build() returns

org.bonitasoft.engine.bpm.bar.form.model.FormMappingModel@3a1e5437[formMappings=[org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@491d9a57[page=custompage\_DamageStructurelForm,target=INTERNAL,type=TASK,taskname=Analyse], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@3f0cb83c[page=custompage\_DamageStructurelForm,target=INTERNAL,type=TASK,taskname=Localisation], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@aeca4b2[page=custompage\_DamageStructurelForm,target=INTERNAL,type=TASK,taskname=Cloture], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@421be634[page=custompage\_ProcessToModifyModelA,target=INTERNAL,type=TASK,taskname=Model Validation Dommage], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@67f11302[page=custompage\_ProcessToModifyModelB,target=INTERNAL,type=TASK,taskname=Model Collect Commentaire], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@3de69a98[page=custompage\_DamageStructurelForm,target=INTERNAL,type=PROCESS\_START,taskname=\<null\>], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@52c060a2[page=custompage\_DamageStructurelForm,target=INTERNAL,type=TASK,taskname=\<null\>], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@4ff71688[page=custompage\_caseoverview,target=INTERNAL,type=PROCESS\_OVERVIEW,taskname=\<null\>], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@20f16577[page=custompage\_caseoverview,target=INTERNAL,type=TASK,taskname=\<null\>], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@29ca19ab[page=custompage\_ProcessToModifyModelB,target=INTERNAL,type=TASK,taskname=v]]]

Some tasks are null (need to be investigate) but there is data.

&nbsp;
