Update Component Task Status with Lightning Message Channel

To change the status of a component task, publish a message through a Lightning message channel and create a Lightning aura component.

Available in: Lightning Experience

Available in: Enterprise and Unlimited Editions with Health Cloud or Health Cloud for Life Sciences


User Permissions Needed
To access Assessment Tasks: Industries Visit permission set

To change a component task’s status, publish to the lightning__industries_componentTaskInput lightning message channel. You must add values to these input parameters.

  • assessmentTaskId: Represents the current assessment task.
  • requestedStatus: Represents the status you want to update. The valid status values are NotStarted, InProgress, and Completed.
  • updatedStatus: Represents the status of the tasks that are updated manually. Use this parameter to refresh the component task.

    The assessmentTaskId input parameter is mandatory, but you also must enter a value for one of the other two parameters.

    Note

  1. Publish a message to lightning__industries_componentTaskInput Lightning message channel with this structure.
    1var message = {
    2assessmentTaskId: "0x00",
    3requestedStatus: "InProgress",
    4};
  2. When the status is updated, a success message is published in the lightning__industries_componentTaskOutput lightning message channel with this structure.
    1outputObject = {
    2assessmentTaskId: "0x000",
    3result: "Success"
    4}
  3. Create a Lightning aura component. Use the sample code in these steps to create your code. Change the status of the task as required.
    1. Click Gear icon, and click Developer Console.
    2. Click File | New | Lightning Component.
    3. Enter a name for your aura component.
    4. Click Submit.
    5. In the Component tab, replace the auto-generated code with this sample code.
      1<aura:component description="Work Order Step progression"
      2implements="flexipage:availableForRecordHome,lightning:isUrlAddressable">
      3
      4<lightning:messageChannel type="lightning__industries_componentTaskInput"
      5aura:id="ComponentTaskInputChannel"/>
      6<lightning:button label="Send Message" title="Send Message" onclick="{!c.sendMessage }"/>
      7
      8</aura:component>
    6. In the Controller tab, replace the auto-generated code with this sample code.
      1({
      2    sendMessage : function(cmp, event, helper) {
      3        
      4         var payload = {
      5            assessmentTaskId : "0egxx00000000MbAAI", // update the assessment Task ID.
      6            requestedStatus  : "Completed"
      7        };
      8        cmp.find("ComponentTaskInputChannel").publish(payload);
      9    }
      10})
  4. Save your changes.
    Use the Lightning aura component in the component task.