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

[QUERY] Define Default Value for Type Rich Text in OpenForm step #239

Open
baycak opened this issue Nov 4, 2023 · 9 comments
Open

[QUERY] Define Default Value for Type Rich Text in OpenForm step #239

baycak opened this issue Nov 4, 2023 · 9 comments
Labels
backend Slack backend issue bug Something isn't working server-side issue with Slack HTTP API

Comments

@baycak
Copy link

baycak commented Nov 4, 2023

Hi,

For the context I have building a Slack App which can submit a form to Slack Channels, with a capability to do Edit for form which already being submitted. Then one of the fields I'm using is using type Schema.slack.types.rich_text.

The question is, is there any way to define default value for type Schema.slack.types.rich_text within a Workflow Form? Since value from type Rich Text is defined as Block Kit instead of plain text

Thank you!

@filmaj filmaj added the question Further information is requested label Nov 6, 2023
@filmaj
Copy link
Contributor

filmaj commented Nov 6, 2023

Yes, you should be able to define an initial_value on it. See the Rich Text Fields reference.

Does that solve your issue?

@baycak
Copy link
Author

baycak commented Nov 7, 2023

Is the initial_value are correct property to be define? Since I'm using Schema.slack.functions.OpenForm instead of Slack Modal. From the documentation itself is using default

The error I've got is attached below when I'm trying to define default value of type Rich Text

parameter_validation_failed - Validation for parameter `fields` failed: elements_param_validation_failed - form_input_types_validate_fail

@filmaj
Copy link
Contributor

filmaj commented Nov 7, 2023

@baycak can you post your full OpenForm step configuration, including all the fields ?

@baycak
Copy link
Author

baycak commented Nov 7, 2023

Attached below @filmaj ,

Open snippet code here
/**
 * For collecting input from users, we recommend the
 * OpenForm Slack function as a first step.
 * https://api.slack.com/automation/functions#open-a-form
 */
const inputForm = UpdateRequestTestingWorkflow.addStep(
  Schema.slack.functions.OpenForm,
  {
    title: 'Update QA Testing Form',
    interactivity: prevInputForm.outputs.interactivity,
    submit_label: 'Update',
    fields: {
      elements: [
        {
          name: 'title',
          title: 'Title',
          type: Schema.types.string,
          default: prevInputForm.outputs.title,
        },
        {
          name: 'description',
          title: 'Description',
          type: Schema.slack.types.rich_text,
          description: 'Fill the description as detail as possible',
          default: prevInputForm.outputs.description,
        },
        {
          name: 'mentioned_to',
          title: 'Mentioned to',
          type: Schema.types.array,
          items: {
            type: Schema.types.string,
            enum: [
              'dummy'
            ],
          },
          description: 'A user groups which responsible to do a QA test',
          default: prevInputForm.outputs.mentioned_to,
        },
        {
          name: 'ui_stage',
          title: 'UI Stage',
          type: Schema.types.string,
          description: 'Testing environment for UI',
          default: prevInputForm.outputs.ui_stage,
        },
        {
          name: 'api_stage',
          title: 'API Stage',
          type: Schema.types.string,
          description: 'Testing environment for API',
          default: prevInputForm.outputs.api_stage,
        },
        {
          name: 'priority',
          title: 'Priority',
          type: Schema.types.string,
          enum: ['Very High', 'High', 'Medium', 'Low', 'Very Low'],
          description: 'Testing priority',
          default: prevInputForm.outputs.priority,
        },
        {
          name: 'estimated_release',
          title: 'Estimated Release',
          type: Schema.slack.types.date,
          description:
            'Estimated release feature / enhancement / bugfix to Production',
          default: prevInputForm.outputs.estimated_release,
        },
        {
          name: 'notion_link',
          title: 'Notion Reference',
          type: Schema.types.string,
          description: 'Fill if necessary',
          default: prevInputForm.outputs.notion_link,
        },
        {
          name: 'jira_link',
          title: 'Jira Reference',
          type: Schema.types.string,
          description: 'Fill if necessary',
          default: prevInputForm.outputs.jira_link,
        },
        {
          name: 'mr_gitlab',
          title: 'MR Gitlab',
          type: Schema.types.string,
          description: 'Fill if necessary',
          default: prevInputForm.outputs.mr_gitlab,
        },
        {
          name: 'apk_build_link',
          title: 'APK Build Link',
          type: Schema.types.string,
          description: 'Fill if necessary',
          default: prevInputForm.outputs.apk_build_link,
        },
        {
          name: 'device_type',
          title: 'Device Type',
          type: Schema.types.string,
          description: 'Fill if necessary',
          default: prevInputForm.outputs.device_type,
        },
        {
          name: 'os_version',
          title: 'OS Version',
          type: Schema.types.string,
          description: 'Fill if necessary',
          default: prevInputForm.outputs.os_version,
        },
        {
          name: 'cc',
          title: 'Cc',
          type: Schema.types.array,
          items: {
            type: Schema.slack.types.user_id,
          },
          description: 'Let others know about the QA test request',
          default: prevInputForm.outputs.cc,
        },
      ],
      required: [
        'title',
        'description',
        'ui_stage',
        'api_stage',
        'priority',
        'mentioned_to',
      ],
    },
  }
);
And for the value of description, can be seen here
[
  {
    "type": "rich_text",
    "block_id": "GS0LV",
    "elements": [
      {
        "type": "rich_text_section",
        "elements": [
          {
            "text": "gasfgasdfasdf",
            "type": "text",
            "style": {
              "bold": true
            }
          },
          {
            "text": "\n",
            "type": "text"
          }
        ]
      },
      {
        "type": "rich_text_list",
        "style": "ordered",
        "border": 0,
        "indent": 0,
        "elements": [
          {
            "type": "rich_text_section",
            "elements": [
              {
                "text": "gasdfasdf",
                "type": "text",
                "style": {
                  "bold": true
                }
              }
            ]
          },
          {
            "type": "rich_text_section",
            "elements": [
              {
                "text": "\\g",
                "type": "text",
                "style": {
                  "bold": true
                }
              }
            ]
          },
          {
            "type": "rich_text_section",
            "elements": [
              {
                "text": "a",
                "type": "text",
                "style": {
                  "bold": true
                }
              }
            ]
          },
          {
            "type": "rich_text_section",
            "elements": [
              {
                "text": "sdf",
                "type": "text",
                "style": {
                  "bold": true
                }
              }
            ]
          },
          {
            "type": "rich_text_section",
            "elements": [
              {
                "text": "a",
                "type": "text",
                "style": {
                  "bold": true
                }
              }
            ]
          }
        ]
      },
      {
        "type": "rich_text_section",
        "elements": [
          {
            "text": "\n",
            "type": "text"
          }
        ]
      },
      {
        "type": "rich_text_list",
        "style": "bullet",
        "border": 0,
        "indent": 0,
        "elements": [
          {
            "type": "rich_text_section",
            "elements": [
              {
                "text": "gasdfasdf",
                "type": "text",
                "style": {
                  "bold": true
                }
              }
            ]
          },
          {
            "type": "rich_text_section",
            "elements": [
              {
                "text": "asd",
                "type": "text",
                "style": {
                  "bold": true
                }
              }
            ]
          },
          {
            "type": "rich_text_section",
            "elements": [
              {
                "text": "fa",
                "type": "text",
                "style": {
                  "bold": true
                }
              }
            ]
          },
          {
            "type": "rich_text_section",
            "elements": [
              {
                "text": "sdf",
                "type": "text",
                "style": {
                  "bold": true
                }
              }
            ]
          }
        ]
      },
      {
        "type": "rich_text_section",
        "elements": [
          {
            "text": "\n",
            "type": "text"
          }
        ]
      },
      {
        "type": "rich_text_preformatted",
        "border": 0,
        "elements": [
          {
            "text": "gadsfasdf",
            "type": "text"
          }
        ]
      }
    ]
  }
]

@filmaj filmaj changed the title [QUERY] Define Default Value for Type Rich Text in Workflow Form [QUERY] Define Default Value for Type Rich Text in OpenForm step Nov 7, 2023
@filmaj
Copy link
Contributor

filmaj commented Nov 7, 2023

Hey @baycak, we are looking into this. I believe it may be a bug on our end. Will keep you posted.

@filmaj
Copy link
Contributor

filmaj commented Nov 7, 2023

@baycak I was able to get this to work by providing the default in an OpenForm rich text field as a string, e.g.:

const inputForm = GreetingWorkflow.addStep(
  Schema.slack.functions.OpenForm,
  {
    title: "Send a greeting",
    interactivity: GreetingWorkflow.inputs.interactivity,
    submit_label: "Send greeting",
    fields: {
      elements: [{
        name: "recipient",
        title: "Recipient",
        type: Schema.slack.types.user_id,
      }, {
        name: "channel",
        title: "Channel to send message to",
        type: Schema.slack.types.channel_id,
        default: GreetingWorkflow.inputs.channel,
      }, {
        name: "message",
        title: "Message to recipient",
        type: Schema.slack.types.rich_text,
        default: 'test',
      }],
      required: ["recipient", "channel", "message"],
    },
  },
);

My guess is that the prevInputForm.outputs.description you are using for the default value is not a string but maybe something else? Perhaps a more complex type?

@baycak
Copy link
Author

baycak commented Nov 7, 2023

Yes @filmaj, by providing value as a string there is no issue. The issue arrived when I'm trying to add default value from previous Form which the value of rich text is as I mentioned before

I believe value from rich text is defined as an array of object right not a string? CMIIW

@filmaj
Copy link
Contributor

filmaj commented Nov 7, 2023

Correct, rich text ends up being an array with a variety of different objects within representing the various kinds of rich text, i.e. italic, bold, bullet points, so on.

I will keep this issue open but have informed the Block Kit team internally about this use case, as I think it is valid.

@filmaj filmaj added bug Something isn't working backend Slack backend issue server-side issue with Slack HTTP API and removed question Further information is requested labels Nov 7, 2023
@baycak
Copy link
Author

baycak commented Nov 7, 2023

I see, well noted @filmaj

Thank you, will waiting for the updates!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Slack backend issue bug Something isn't working server-side issue with Slack HTTP API
Projects
None yet
Development

No branches or pull requests

2 participants