Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Dynamic options in OpenForm step fields #355

Open
ynkze opened this issue Aug 27, 2024 · 2 comments
Open

[FEATURE] Dynamic options in OpenForm step fields #355

ynkze opened this issue Aug 27, 2024 · 2 comments
Labels
feature request New feature or request question Further information is requested

Comments

@ynkze
Copy link

ynkze commented Aug 27, 2024

Question

For instance, typically you provide some enum values in the form options:

        name: "team2",
        title: "Team 2",
        type: Schema.types.array,
        items: {
          type: Schema.types.string,
          enum: ["one", "two", "three"],
        },

Instead of ["one", "two", "three"], I have a fetchName from datastore function to get an array of names because the names might change so I do not want hardcoded enums. However for Workflow I am not allowed to add a step before OpenForm because of the following problem:

Interactivity at step 2 needs to be mapped to an interactivity in step 1's output (invalid_interactivity_pointer)

This means that I can't invoke any function via addStep prior to the form, is there a workaround?

@filmaj filmaj added the question Further information is requested label Aug 27, 2024
@filmaj
Copy link
Contributor

filmaj commented Aug 27, 2024

I am trying to understand what you are trying to accomplish, is the following correct?

  1. Run some custom step to retrieve data from a datastore
  2. Use the output of the custom step as a means of constraining the possible values for a particular OpenForm step's field's dropdown options

If the above is accurate, that's not possible at this time (at least not in the "nice" way you've described it) - though we are actively planning on adding support for this feature in the coming months. The main reason is that Workflow configurations are static and resolved at deploy-time. That is, the specific setup for the OpenForm step is defined statically and in whole via the app manifest. If you run slack manifest and inspect the contents of the workflows property in the outputted JSON, you will see the entire workflow configuration defined there.

A workaround in the mean time is to build your own form using the available interactivity features in the deno SDK. You can build a full interactive modal yourself, using all Block Kit elements available within Modals (specifically the Input block). There is one Block Kit element in particular, the externally-sourced select menu, that you can build a form in a modal with that should meet the use case you describe. Custom steps can register a 'block kit suggestion handler' to run some code at runtime whenever the externally-sourced select menu is typed into.

I have a sample app on GitHub that shows off building a full interactive modal flow using the deno-slack-sdk: https://github.com/filmaj/interactive-approval

It's an example 'approval flow' app that posts a message with an approve and a deny button. If the end-user clicks deny, it will open a fully-featured modal and implements its own form. One of these form fields is an externally-sourced select menu; in this example app it reads from a bundled .csv file to provide dynamic options in this select menu.

Hope that helps!

@filmaj filmaj added the feature request New feature or request label Aug 27, 2024
@filmaj filmaj changed the title [QUERY] Can I add data from datastores to form dropdown options? [FEATURE] Dynamic options in OpenForm step fields Aug 27, 2024
@ynkze
Copy link
Author

ynkze commented Aug 27, 2024

Thanks for the detailed reply! What you described is exactly what I need to work with, specifically I didn't know that workflows does not have the ability to resolve dynamic values, so the interactive modal looks like a good workaround. If this feature gets implemented that's great, but in the meantime I will try the interactive modal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants