Dynamic URL in the body of a Email connector

1
0
-1

Good morning
i want to do this in Bonita: send an Email with a link to my ERP in its body. This is the static URL of my ERP:
http://hostname:numberport/session&programme&code

I want to retrieve the information about the code dynamically from a variable (business object defined in the business data model set in Bonita). This variable is defined as a java object as Socio#getCodice. I am trying to substitute this variable to my static ERP code at the end of my URL but it doesn't work. I have tried to put Socio#getCodice, #getCodice, getCodice, getCodice() in the place of my code at the end of the URL but no one works.
How can i do that?
Thank you very much.
Fabio.

1 answer

1
0
-1

Hi,

Here is an example of message body definition to include value of an attribute (named: desination) of a business variable (named: travelRequest) in an URL:

Here is an email that include a dynamic link based on business variable
value: https://localhost/destination-information/${travelRequest.destination}
The dollar sign and curly brace allow to include Groovy code that will be evaluated.

Comments

Submitted by f.aversa_1414431 on Thu, 11/07/2019 - 12:23

If i follow your instructions:

http://hostname:numberport/session&programme&${Socio.Codice}

Bonita returns me this error while i test:

Unsupported expression type for testing:
-Input parameter 'message' use an expression containing unreachable reference

In my case, Socio is the business data model (business variable) and Codice its attribute (type=text).
This business variable works regularly in the workflow.

Thank you very much.

Fabio.

Submitted by antoine.mottier on Thu, 11/07/2019 - 14:27

Is it possible for you to share your process .bos file?

Also can you let me know where did you put your connector (beginning of process, end, on a task..)? Are you sure that business variable is initialized when you try to use it?

Submitted by f.aversa_1414431 on Thu, 11/07/2019 - 14:40

1) Yes, it is. How can i extract that?
2) End of a process
3) I am quite sure because if i use it in the body of my email with Java it appears regularly.

Let me know.

Thanks.

Fabio.

Submitted by antoine.mottier on Thu, 11/07/2019 - 14:47

From Bonita Studio, you can click on "File" -> "Export" menu. It will create a .bos file. You can then upload it on Google Drive, Dropbox... and share the link here.

Also can you add this as a comment on my answer? This will avoid to create several "answers" that don't actually answer to your question.

Submitted by f.aversa_1414431 on Thu, 11/07/2019 - 14:59

I have Bonita Community, and by File-->Export i don't have the possibility to export a .bos file.
Thanks.

Submitted by antoine.mottier on Thu, 11/07/2019 - 15:31

In the export screen (after you clicked on File --> Export), "Detination path" should be a path to a file that will be created with .bos extension. I use Bonita Studio Community Edition and I have this feature and it is available since version 6.0.0.

Submitted by f.aversa_1414431 on Thu, 11/07/2019 - 15:52
Submitted by f.aversa_1414431 on Thu, 11/07/2019 - 15:56

I set the connector out = email on the 'Inserimento dati amministrativi' task. I put the URL in the Message of the email: i followed your instructions but it seems not working.
Thanks.

Submitted by antoine.mottier on Thu, 11/07/2019 - 16:22

Your business variable is named socio not Socio. Socio is the name of the business object (the type definition). If you update the script in the email connector it should work.

Submitted by f.aversa_1414431 on Thu, 11/07/2019 - 16:35

So, i have to put this url?
http://localhost:10000/EXTCMD&MGD020&M&${socio}

or this?
http://localhost:10000/EXTCMD&MGD020&M&${socio.Codice}

They both give me the error saw before.
Thanks.

Submitted by f.aversa_1414431 on Tue, 11/12/2019 - 15:45

Hi
could you please answer to my last question below?
Thank you very much.
Fabio.

Submitted by antoine.mottier on Tue, 11/12/2019 - 15:57

You should use ${socio.Codice}

Note that in your BDM I recommend to use lower case for the first letter of the attributes. We use Java code convention (https://www.oracle.com/technetwork/java/codeconventions-135099.html): classes for BDM objects and variables for BDM attributes.

Submitted by f.aversa_1414431 on Tue, 11/12/2019 - 17:42

It works now.
Thank you very much.
Bye.
Fabio.

Notifications