Home > Forum > Forms > REST request on a new form

REST request on a new form
0

Hi,
I’d like to ask if it’s possible to trigger a REST request action when a form opens while loading default values or on onchange field.

For instance, when a user creates a new element, the email address is assigned to the 'Person' field as a default value. I would then like to trigger a REST action to fetch data from an external API based on that value and load the remaining form fields.

Currently, the only workaround I know is using a additional transition path (e.g., "Calculate") with a REST request action. On-entry action on the Start Step doesn't execute on a new, unsaved element.

Is there a standard way to achieve this on form load or on a on-change field?

MVP

Hi Adam,

I have three ideas:

1. Show the information in following steps
Ok, this will depend on the use case, but maybe these information are not relevant for the person filling out the form and just clutter the form. If this would be the case, it would be even better to show these information just in the next step and you can use the REST action.

2. Use a choose field which source it the REST endpoint
Maybe you can create a data source for this REST endpoint. In this case you could create a Choose field which uses this data source. If you set the mode to Auto complete/Popup Search mode, you will see the the "Target field" column in the advanced configuration. This will allow you to populate further fields based on the selected record, whenever the selected value (email) changes.

3. Setting values in OnChange
3.a) You can execute a form rule in the Onchange, this form rule can set a field to a value. The value would be the result of a business rule in which you can return a single value from the REST endpoint, if you can create a data source.
3.b) You can utilize the User Defined API with running mode "Execute automation".
This will allow you to define a REST endpoint, which calls your REST endpoint and you can define which properties are returned. Your endpoint can be executed via JavaScript and you can process the results with JavaScript to populate other fields. I have a draft blog post about this example, but it's not finished yet.
If you have no idea, what User Defined APIs are, you can read up on those here:
https://daniels-notes.de/posts/2026/user-defined-api-overview-part-1
https://daniels-notes.de/posts/2026/user-defined-api-part-4-execute-automation

Best regards,
Daniel

In reply to: Daniel Krüger (DCCS)

Hi Adam,

I have three ideas:

1. Show the information in following steps
Ok, this will depend on the use case, but maybe these information are not relevant for the person filling out the form and just clutter the form. If this would be the case, it would be even better to show these information just in the next step and you can use the REST action.

2. Use a choose field which source it the REST endpoint
Maybe you can create a data source for this REST endpoint. In this case you could create a Choose field which uses this data source. If you set the mode to Auto complete/Popup Search mode, you will see the the "Target field" column in the advanced configuration. This will allow you to populate further fields based on the selected record, whenever the selected value (email) changes.

3. Setting values in OnChange
3.a) You can execute a form rule in the Onchange, this form rule can set a field to a value. The value would be the result of a business rule in which you can return a single value from the REST endpoint, if you can create a data source.
3.b) You can utilize the User Defined API with running mode "Execute automation".
This will allow you to define a REST endpoint, which calls your REST endpoint and you can define which properties are returned. Your endpoint can be executed via JavaScript and you can process the results with JavaScript to populate other fields. I have a draft blog post about this example, but it's not finished yet.
If you have no idea, what User Defined APIs are, you can read up on those here:
https://daniels-notes.de/posts/2026/user-defined-api-overview-part-1
https://daniels-notes.de/posts/2026/user-defined-api-part-4-execute-automation

Best regards,
Daniel

Hi Daniel,
Thank you very much for your reply and some great ideas. I implemented solution 3b, and it completely solves my problem !

Other solutions using a data source unfortunately won't work for my business case.
However, 3b isn't easily portable because when using a different API or receiving a different response body from the request, we have to change the JS (or try to parameterize it at least a little).
I'm looking forward to your blog post about the one you mentioned ;)

Best regards,
Adam