function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AJAYAJAY 

How to get the value of a variable from a Child LWC that is embedded in a parent LWC and pass the child JS variable value to Parent JS

I have a LWC component (parent) where there is a variable like
firstfieldAPIname , secondField API name in the LWC and this LWC components picks all the values of picklist fields using data.picklistfieldValues. and passes into some variables which are like  optionValuesFirstSet = {controlling:[], dependent:[]}; to store the controlling field values , dependent values of the fields basing on record type.

I have another LWC Component(Child) - which uses the parent LWC component LWC and some picklist fields are being passed into the child HTML.

Something like this:
<c-parent-lwc
  first-picklist-field-api-name ="Type"
  second-picklist-field-api-name = "Area"
  third-picklist-field-api-name = "SubArea"
> <c-parent-lwc/>


Now i get the values on the component, please see screenshot. 

I even got the current values of the fields Type,Area and sub Area on the record in the child JS, however - how do i show on the UI. 

User-added image




User-added image




 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Ajay,

>> https://salesforcediaries.com/2019/07/24/lwc-communication-part-1-passing-data-from-parent-to-child-component/

I think the above way of events can help you in communication between two LWC components.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
jhonhenkee alijhonhenkee ali
Hi Ajay i try this but he didnot work proper. some modifiaction plz and appcariete your work its more helpfull (https://basketballshout.com/)in future.