Add Jira Expressions in Validators / Conditions using Forge

I am able to achieve individual Jira expressions in validators and conditions using Forge in my manifest.yml file. However, I need to override these Jira expressions using a custom UI. In the UI, if I input a Jira expression, I want Forge to read and validate it. How can I achieve this?

App.js:

 useEffect(() => {
    view.getContext().then((ctx) => {
      let config = {
        searchString: '',
      };
      try {
        config = JSON.parse(ctx.extension.validatorConfig);
      } catch {
        // noop
      }

      setExtensionData(ctx.extension);
      setValidatorConfig(config);
    });
  }, []);

  useEffect(() => {
    workflowRules
      .onConfigure(async () => JSON.stringify(validatorConfig))
      .catch((err) => {
        console.error(`Unable to add workflow rule configuration callback: ${err}`);
      });
  }, [validatorConfig]);

  if (!extensionData) {
    return <p>Validator is loading.</p>;
  }

  if (extensionData.entryPoint === 'view') {
    // display validator configuration
    return <p>Summary field must contain text: "{validatorConfig.searchString}"</p>;
  }
  // create/edit view below
  const handleOnChange = (evt) => {
    setValidatorConfig({
      searchString: evt.target.value,
    });
  };

Manifest.yml

modules:
  jira:workflowValidator:
    - key: jira-workflow-example-workflow-validator-custom-ui-expression
      name: jira-workflow
      description: A Jira workflow validator example using expression, custom UI, and
        validator configuration.
      expression: issue.assignee != null
      errorMessage:
        expression: "'The transition failed because issue summary doesn\\'t include \"'
          + config['searchString'] + '\".'"
      view:
        resource: custom-ui-expression
      edit:
        resource: custom-ui-expression
      create:
        resource: custom-ui-expression
  trigger:
    - key: jira-workflow-failed-expression-trigger
      function: listen
      events:
        - avi:jira:failed:expression
  function:
    - key: listen
      handler: index.listen
resources:
  - key: custom-ui-expression
    path: static/custom-ui-expression/build
1 Like

I tried for a whole day. The development documentation said it could be overridden, but when I tested it, it didn’t work. I can only call config within the expression. Replacing it as a whole would result in constantly returning false.