Insert data in a .docx/.odt template connector didn't handle the sub-structure of complex object

1
0
-1

hello ,

i follow this documentation Insert data in a .docx/.odt template connector | Bonita Documentation (bonitasoft.com), to be able to use the connector 'insert data in a .docx/.odt template' that fills a specified template file by inserting values coming from the current process instance.

i used the template example for Leave Request submission and approval,i followed all the documentation and in configuration of the connector i added the key named 'user', that is mapped to the business variable 'user',

it said in this example that

  • If the keys are mapped with complex objects, pass the high level object to the mapping (eg. 'user'). The connector will handle the sub-structure of this complex object (eg. ${user.firstName}),

but in my case ${user.firstName} (and all sub-structure of 'user' complex object) didn't display nothing in the template, why ? any help please

Comments

Submitted by romain.bioteau on Mon, 02/20/2023 - 09:05

Hi,

Did you have a look at the engine logs to troubleshoot the issue ? It should indeed work properly.

Submitted by webDev on Mon, 02/20/2023 - 09:35

how i will do that? , you mean if i tried to log "user.firstName" in the script , yes i did it, and it give me result but the issue is in the docx template didn't display the value of ${user.firstName}!

can you explain more how can i troubleshoot the issue?

Submitted by romain.bioteau on Mon, 02/20/2023 - 10:35

From a Studio, Help menu > Bonita engine logs

Submitted by webDev on Mon, 02/20/2023 - 11:27

yes i did that, and as i said before that the issue is in the docx template didn't display the value of ${user.firstName}!

2 answers

1
0
-1
This one is the BEST answer!

In your connector configuration, the mapping is not good. You are using script expression that return java.lang.String so your business variable are automatically cast into String values at runtime.
You can either bind the business variable directly in the expression editor without using a script expression, or set the return type expression to the proper business object type (eg: com.company.model.MyUser)

If you return a String then, then the template engine will not be able to navigate in your objects.

HTH

1
+1
-1

Hi,

I have made quick test in 2022.2 and did not reproduce your issue. Can you share more details of how you have configured your connector and template ?

Here is the bos file with my test.

HTH
Romain

Comments

Submitted by webDev on Tue, 02/21/2023 - 10:19

i want to share my project "leaveRequest" file , but i don't how to upload it here, the same thing with the pictures , I didn't know how to upload it from my desktop (even if i copy paste the images it didn't display in the comment)

please how can i test the bos file that you sent me.

any help please

Submitted by webDev on Wed, 02/22/2023 - 08:22

this is my project file leaveRequest

could you please test it, and tel me where is the issue in my case?

thank you !

Submitted by romain.bioteau on Wed, 02/22/2023 - 09:47

In your connector configuration, the mapping is not good. You are using script expression that return java.lang.String so your business variable are automatically cast into String values at runtime.
You can either bind the business variable directly in the expression editor without using a script expression, or set the return type expression to the proper business object type (eg: com.company.model.MyUser)

If you return a String then, then the template engine will not be able to navigate in your objects.

HTH

Submitted by webDev on Wed, 02/22/2023 - 10:06

thank youuu so much it works !

Notifications