• SAHANA GHOSH
  • NEWBIE
  • 35 Points
  • Member since 2014
  • Consultant
  • Deloitte USI

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 7
    Replies

Hi,

I am trying to achieve bidirectional  communication between 2 independent components, one an aura component and the other one a LWC. I am able to achieve one way communication(ie from LWC TO aura / aura TO LWC ) using Lightning messaging service, however how to achieve bi-directional?
Thanks,

Sahana

Will create a checkbox/text field, that will be populated using trigger, however will be based on some non-deterministic field checks. Can i index that field then ?
I have asked salesforce support to create an indexed field to optimize my query ? How do i migrate the same to i higher orgs and finally to Production?
Page - 
<aura:component implements="force:appHostable" controller="lightningCreateBooks">
    <aura:attribute name="book" type="Book__c"/>
    <lightning:layoutItem padding="around-small" size="6">
    <article class="slds-card">
        <div class="slds-p-around_medium" size="6">
            <lightning:recordEditForm aura:id="createBooks"
                                      objectApiName="Book__c"
                                      onsubmit="{!c.handleSubmit}">
                <lightning:messages />
                <lightning:input aura:id="Bookform" label="Book Name"
                                         name="bname"
                                         value="{!v.book.Name}"
                                         />
                <lightning:input aura:id="Bookform" label="Book Language"
                                         name="blanguage"
                                         value="{!v.book.Book_Language__c}"
                                         required="false"/>
                <lightning:input aura:id="Bookform" label="Author Name"
                                         name="authname"
                                         value="{!v.book.Author__c}"
                                         required="false"/>
                <lightning:button type="submit" name="Submit" label="submit" class="slds-m-top_medium"/>
            </lightning:recordEditForm>
        </div>
    </article>
    </lightning:layoutItem>
</aura:component>

JS  Controller:

({
    Submit : function(component, book) {
        var action = component.get("c.saveBook");
        action.setParams({
            "bk": book
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                //var expenses = component.get("v.expenses");
                //expenses.push(response.getReturnValue());
                //component.set("v.expenses", expenses);
            }
        });
        $A.enqueueAction(action);
    },
    handleSubmit: function(component,event,helper){
        
    }
})

Apex Controller :

public class lightningCreateBooks {

    @AuraEnabled
    public static Book__c saveBook(Book__c bk) {
        upsert bk;
        return bk;
    }
}

___________________________________________

I am getting this error :

Uncaught TypeError: Cannot read property 'Name' of null throws at https://sahana2004-dev-ed.lightning.force.com/auraFW/javascript/kHqYrsGCjDhXliyGcYtIfA/aura_prod.js:547:410
public List<Account> acclist = new List<Account>();
for(integer i =0; i<10; i++){
    Account acc = new Account();
    acc.name='Account'+i;
    acc.Industry = 'Agriculture';
    acclist.add(acc);
}
Database.SaveResult[] sr= database.insert(acc,false);
for(database.SaveResult srtest : sr){
    if(srtest.isSuccess()){
        system.debug('success');
    }
    else{
        for(database.error e : srtest.getErrors()){
            system.debug('**** '+e.getMessage());
        }
    }
}


I am getting -
variable doesnt exist : acc
error while executing this in anonymous window.
Component : 
<aura:component controller="displayColoursClass">
    <aura:attribute name="Colours" type="String[]" default="cyan, yellow, magenta"/>
    <aura:iteration items="{!v.Colours}" var="s">
        {!s}
    </aura:iteration>
    <lightning:button onclick="{!c.getNewList}" label="Update"/>
</aura:component>

Apex  class :
public class displayColoursClass {
    public final  List<String> colourlist;
    @AuraEnabled
    public List<String> getcolornames(){
        colourlist.add('Red');
        colourlist.add('Green');
        colourlist.add('Blue');
        colourlist.add('Yellow');
        system.debug('colourlist : '+colourlist);
        return colourlist;
    }
}
JS Controller :
({
    getNewList : function(component, event, helper) {
        var action = component.get("c.getcolornames");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var stringItems = response.getReturnValue();
                component.set("v.Colours", stringItems);
            }
        });
        
        $A.enqueueAction(action);
    }
})

I am getting the below error when i click on 'Update button'
This page has an error. You might just need to refresh it. Unable to find action 'getcolornames' on the controller of c:displayColours Failing descriptor: {c:displayColours}
Lightning Component  - 
<aura:component implements="flexipage:availableForAllPageTypes, force:hasRecordId" access="global" controller="addBooks">
    <aura:attribute name="bookToAdd" type="Books__c" />
    <aura:attribute name="authId" type="String" />
    
    <div class="Styling">
        <lightning:card title="Quick register Books">
            
            <lightning:input label = "Book Name : " value="{!v.bookToAdd.Name}" required="true" />
            <lightning:input label = "Book Price : " value="{!v.bookToAdd.Price__c}" required="true" />
            <lightning:button variant="brand" label="Add books" title="Add books" onclick="{! c.addBooks }"/>
        </lightning:card>
    </div>
</aura:component>

JS - 
({
    addBooks : function(component, event, helper) {
        var action = component.get('c.addbooks');
        component.set('v.authId',v.recordId);
        console.log('v.recordId***',v.recordId);
        action.setParams({
            b : component.get('v.bookToAdd'),
            authId : component.get('v.authId')
        });
        action.setCallback(this, function(response){
            
        },'ALL');
        $A.enqueueAction(action);
    }
})

Controller - 
public class addBooks {
    @AuraEnabled
    public static void addbooks(Books__c b, Id authId){
        if((b.Name != NULL ||b.Name !='') && (b.Price__c >0)){
            b.Author__c=authId;
            insert b;
        }
    }
}

I get the following error when I try to enter input -

Error
Here goes my Lightning component - 

<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="cboard_seeContacts">
    <aura:attribute name="accId" type="String" />
    <aura:attribute name="Con" type="Contact" 
                    default="{sObjectname: 'Contact',
                    FirstName:'Roza',
                    LastName:'Stalin',
                    Phone:'8981103780',
                    Email:'rozaStalin@cboard.com'}"/>
    <div class="slds-p-around_medium">
        <lightning:input name="First Name" type="text" label = "First Name" value="{!v.con.FirstName}"/>
        <lightning:input name="Last Name" type="text" label = "Last Name" value="{!v.con.LastName}"/>
        <lightning:input name="Phone" type="phone" label = "Phone" value="{!v.con.Phone}"/>
        <lightning:input name="Email" type="email" label = "Email" value="{!v.con.Email}"/><br/><br/>
        <lightning:button label="Quick Create Contact" variant="Brand" onclick="{!c.doSave}"/>
    </div>
</aura:component>

Controller - 

public class cboard_seeContacts {
    
    @AuraEnabled
    public static List<Contact> ContactList(string accId){
        return [Select Id, FirstName,LastName from Contact where AccountId =:accId];
    }
    
    @AuraEnabled
    public static Contact createContact(Contact c, Id AccountId){
        c.AccountId=AccountId;
        insert c;
        return c;
    }
}

JS-  
({
    doSave : function(component, event, helper) {
        var action = component.get('c.createContact');
        action.setParam({
            c : component.get('v.Con'),
            AccountId : component.get('v.accId')
        });
        action.setCallBack(this, function(response){
            var state= response.getState();
            if(state === 'SUCCESS' || state ==='DRAFT'){
                var reposneValue = response.getReturnvalue();
            }
        },'ALL');
        $A.enqueueAction(action);
    }
})


I am unable to figure out why the inputs and button is not working. Any help will be appreciated. 
 
Unable to edit/preview VF pages and apex classes. This error is appearing - An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com! 

Error ID: 648673073-170378 (-617778647)
Page - 
<aura:component implements="force:appHostable" controller="lightningCreateBooks">
    <aura:attribute name="book" type="Book__c"/>
    <lightning:layoutItem padding="around-small" size="6">
    <article class="slds-card">
        <div class="slds-p-around_medium" size="6">
            <lightning:recordEditForm aura:id="createBooks"
                                      objectApiName="Book__c"
                                      onsubmit="{!c.handleSubmit}">
                <lightning:messages />
                <lightning:input aura:id="Bookform" label="Book Name"
                                         name="bname"
                                         value="{!v.book.Name}"
                                         />
                <lightning:input aura:id="Bookform" label="Book Language"
                                         name="blanguage"
                                         value="{!v.book.Book_Language__c}"
                                         required="false"/>
                <lightning:input aura:id="Bookform" label="Author Name"
                                         name="authname"
                                         value="{!v.book.Author__c}"
                                         required="false"/>
                <lightning:button type="submit" name="Submit" label="submit" class="slds-m-top_medium"/>
            </lightning:recordEditForm>
        </div>
    </article>
    </lightning:layoutItem>
</aura:component>

JS  Controller:

({
    Submit : function(component, book) {
        var action = component.get("c.saveBook");
        action.setParams({
            "bk": book
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (state === "SUCCESS") {
                //var expenses = component.get("v.expenses");
                //expenses.push(response.getReturnValue());
                //component.set("v.expenses", expenses);
            }
        });
        $A.enqueueAction(action);
    },
    handleSubmit: function(component,event,helper){
        
    }
})

Apex Controller :

public class lightningCreateBooks {

    @AuraEnabled
    public static Book__c saveBook(Book__c bk) {
        upsert bk;
        return bk;
    }
}

___________________________________________

I am getting this error :

Uncaught TypeError: Cannot read property 'Name' of null throws at https://sahana2004-dev-ed.lightning.force.com/auraFW/javascript/kHqYrsGCjDhXliyGcYtIfA/aura_prod.js:547:410
Here goes my Lightning component - 

<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="cboard_seeContacts">
    <aura:attribute name="accId" type="String" />
    <aura:attribute name="Con" type="Contact" 
                    default="{sObjectname: 'Contact',
                    FirstName:'Roza',
                    LastName:'Stalin',
                    Phone:'8981103780',
                    Email:'rozaStalin@cboard.com'}"/>
    <div class="slds-p-around_medium">
        <lightning:input name="First Name" type="text" label = "First Name" value="{!v.con.FirstName}"/>
        <lightning:input name="Last Name" type="text" label = "Last Name" value="{!v.con.LastName}"/>
        <lightning:input name="Phone" type="phone" label = "Phone" value="{!v.con.Phone}"/>
        <lightning:input name="Email" type="email" label = "Email" value="{!v.con.Email}"/><br/><br/>
        <lightning:button label="Quick Create Contact" variant="Brand" onclick="{!c.doSave}"/>
    </div>
</aura:component>

Controller - 

public class cboard_seeContacts {
    
    @AuraEnabled
    public static List<Contact> ContactList(string accId){
        return [Select Id, FirstName,LastName from Contact where AccountId =:accId];
    }
    
    @AuraEnabled
    public static Contact createContact(Contact c, Id AccountId){
        c.AccountId=AccountId;
        insert c;
        return c;
    }
}

JS-  
({
    doSave : function(component, event, helper) {
        var action = component.get('c.createContact');
        action.setParam({
            c : component.get('v.Con'),
            AccountId : component.get('v.accId')
        });
        action.setCallBack(this, function(response){
            var state= response.getState();
            if(state === 'SUCCESS' || state ==='DRAFT'){
                var reposneValue = response.getReturnvalue();
            }
        },'ALL');
        $A.enqueueAction(action);
    }
})


I am unable to figure out why the inputs and button is not working. Any help will be appreciated. 
 
Unable to edit/preview VF pages and apex classes. This error is appearing - An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com! 

Error ID: 648673073-170378 (-617778647)