How to populate a field with dynamic data from a Script?
New to Windmill, I have a script that grabs a list of users from Office365. It currently just returns a json with Label and Value
I want to use a from and populate this highlighted field, but I cant figure out how to reference the bg_1, am I being stupid?
thanks!

4 Replies
I think I have realized that I can do this for fields but the form type no, unless I generate the JSON manually š
@Ask Inkeep
Thanks for tagging me @Daten. I'll look through relevant sources and get back to you shortly.
Answer
Based on your question about populating fields with dynamic data from a script, you'll want to use Windmill's Dynamic Select feature. This allows you to create select fields with options that dynamically recompute based on other input values (1) .
For scripts, you need to export both a type and a function. Here's the exact pattern:
For flows, the implementation is different - you only need to define functions that match your flow input field names exactly:
The key points:
- Your Office365 user list script should return an array of objects with
value and label properties
- The select options recompute dynamically based on other input arguments
- You can implement custom filtering and sorting logic within your function
Since you're working with Office365 users, your dynamic select function would call your existing script and transform the results into the required {value, label} format.
For more complex scenarios, you can also use Windmill's API programmatically - check the OpenAPI specification for available endpoints to manage scripts and their execution.
ā
To learn more, see the sources I considered:
[1] JSON schema and parsing
ā
Feel free to tag @Ask Inkeep with additional questions.so my script is modified, no problem there, but within the app designer I want to use these dynamic values in the from component, but it seems I cannot assign the values per field @Ask Inkeep
@Ask Inkeep
Thanks for the follow-up, @Daten. I'll get back to you soon.
Answer
For populating Form component fields with dynamic data in Windmill apps, you have several options:
Dynamic Enums Configuration
The Form component supports dynamic enum values through the Default enums configuration (1) . This enables setting form enum values dynamically using an object where keys are field names and values are arrays of strings .
Using Background Runnables
You can create a background runnable that fetches your Office365 users and then connect it to your form fields . Background runnables execute on the server and can be triggered on app refresh or when their input changes (2) .
Frontend Script Approach
You can use frontend scripts with the
setValue function to populate form fields dynamically (1) (2) :
(2)
This function sets or forces the value of a component, which can be useful when connection patterns aren't the easiest approach (1) (2) .
Connecting Components
To connect your script output to form fields, you need to:
1. Create your background runnable that fetches Office365 users
2. In the Form component configuration, use the Default enums setting (1)
3. Connect this to your background runnable output using eval or the connection interface (3)
The key is that fields in forms are called properties and can be connected to other components or evaluated (1) . They can be filled as JSON and are displayed in the form interface.
Since you're working with API-based solutions, you can also leverage Windmill's API directly through the OpenAPI specification to programmatically manage form data and component connections.
If you need to click the "Ask for help" button to tag a team member for more specific guidance on your form configuration setup.
ā
To learn more, see the sources I considered:
[1] Form
[2] Runnable editor
[3] How can I use the new variables of a form in a flow?
ā
Feel free to tag @Ask Inkeep with additional questions.