Your event name does not match here.
<c:customlwc onhandleResponse="{!c.handleResponse}"/>
You are firing event with name = handleSCResponse
, so you need to prefix on
to your event name, ex onhandlescresponse
. The corrected code of handling it from the parent component is below.
<c:customlwc onhandlescresponse="{!c.handleResponse}"/>
So in detail, this is how you fire an event.
const eventName = 'onhandlescresponse';
const event = new CustomEvent(eventName, {
detail: { message: 'Operation completed successfully' }
});
this.dispatchEvent(event);
This is how you handle it.
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction">
<c:customlwc onhandlescresponse="{!c.handleResponse}"/>
</aura:component>
Although it is supported in the aura parent, its recommended to give the lowercase name for an event.
It's the event name with "on" prefixed.
<c:my-lwc-component oncaserecordchange="{!c.handleCaseRecordChange}" />
You can read more about it in the documentation.
For the moment, the Aura compiler doesn't know what events can be fired from LWC, so be sure not to have any typos, or your event will be missed.
The documentation doesn't mention a way to broadcast to Aura components, but once you fire up from LWC to Aura, you can fire an Application Event. This is mentioned in this Trailhead module:
You can optionally fire a new Aura event to communicate with other Aura components.
This appears to be the only path forward for now. If we get pubsub for Aura, then we'd be able to use that instead.
Best Answer
In the new salesforce release Spring'20, we have this privilege to set the predefined values. We can now make the field API names and their values as a string and pass it to pageReference.state.defaultFieldValues attribute on standard__objectPage page reference types.
You can have the look here - https://releasenotes.docs.salesforce.com/en-us/spring20/release-notes/rn_lc_navigate_to_record_dfv.htm
For instance -
Note - Spring'20 is only available for sandboxes for now.