0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

LWCからモーダルで画面フローを表示する

Posted at

LightningModalとLightningFlowを使用して、画面フローを簡単にモーダル表示することが可能です。

モーダル

modal
<template>
  <lightning-modal-header label={title}></lightning-modal-header>
  <lightning-modal-body>
    <lightning-flow flow-api-name={flowName} flow-input-variables={inputVariables} onstatuschange={handleStatusChange}>
    </lightning-flow>
  </lightning-modal-body>
</template>
import { api } from "lwc";
import LightningModal from "lightning/modal";

export default class FlowSampleModal extends LightningModal {
  @api title;
  @api flowName;
  @api inputVariables;

  handleStatusChange(event) {
    if (event.detail.status === "FINISHED" || event.detail.status === "FINISHED_SCREEN") {
      this.close();
    }
  }
}

使用方法

<template>
  <lightning-button
    label="画面フロー呼び出し"
    onclick={handleClick}
  ></lightning-button>
</template>
import { LightningElement, api } from "lwc";
import flowModal from "c/flowSampleModal";

export default class FlowSample extends LightningElement {
  @api recordId;

  handleClick(event) {
    flowModal.open({
      title: "サンプル",
      flowName: "ScreenFlowName",
      inputVariables: [
        {
          name: "recordId",
          type: "String",
          value: this.recordId
        }
      ]
    });
  }
}

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?