• Aakanksha Singh
  • NEWBIE
  • 114 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 54
    Replies
Hi, 

I want to display list of accounts with contacts in lightning page. Here the code i have written. Here accounts are displaying but contacts are not display. Please help me to display the accounts with contacts.

Thank you.


 
<aura:component controller="accountsWithContactsClass" implements="flexipage:availableForAllPageTypes" access="global">
	 
    <aura:attribute name="accounts" type="Account[]" />
    <ui:button label="click this" press="{!c.myAction}" />
    <table>
            <tr><td><b>Name</b></td><td><b>Industry</b></td></tr>

    <aura:iteration items="{!v.accounts}" var="accs1" >
        <tr>   
        <td> {!accs1.Name}  </td>
         
      <td>   {!accs1.Industry}  </td> 
      <!--   <td>   {!accs1.Contacts.lastName}  </td> -->
        </tr>     
     <tr>   <aura:iteration items="{!v.accs1.contacts}" var="con1" >
            
             <td>{!con1.lastName} </td>
            
        </aura:iteration></tr>
     </aura:iteration>                                            
        </table>
    
</aura:component>








({
	myAction : function(component, event, helper) {
		var action =component.get("c.getAllAccounts");
        console.log('The action value is: '+action);
         action.setCallback(this, function(a){ 
             
            component.set("v.accounts", a.getReturnValue());
           //  console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
            console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
          
        });
        $A.enqueueAction(action);
	}
})











public class accountsWithContactsClass {

@auraEnabled
public static list<account> getAllAccounts()
    {
       list<account> accs =[select id,name,phone,industry,(select lastName from contacts) from account limit 10];
      //  list<account> accs =[select id,name,phone,industry from account limit 10];
     //   return [select Id,Name from account limit 10];
     return accs;
    }
}

 
Hello everyone,
Is there any way to pass the value of an input text field in the vf page to lightning component, through a shared controller??

Thank You
Aakanksha Singh
Hello Everyone,
I want to know how can we reload an iframe which contains a visualforce page,so that the value in visualforce page could be updated, through a button in lightning component.
P.S.- I don't have any code regarding it.
Thanks
Regards
Hello everyone,
I need to know how can I perform mass delete operation with the use of checkboxes.
Here is my component.
<pre>
<aura:component implements="force:appHostable" controller="AccountListController">
<aura:attribute name="accounts" type="Account[]"/>
<aura:handler name="init" value="{!this}" action="{!c.getAccount}" />
<ui:button class="slds-button slds-button--destructive" press="{!c.delete}">Delete</ui:button><!--Mass Delete operation-->
<table class="slds-table slds-table--bordered slds-max-medium-table--stacked-horizontal">
            <thead>
                <tr class="slds-text-heading--label ">
                    <th class="slds-is-sortable" scope="col">
                        <ui:inputCheckbox label="" class="check" aura:id="master" click="{!c.checkAll}"/>
                        Action                        
                    </th>
                    <th class="" scope="col">Account Name</th>
                </tr>  
            </thead>
            <tbody>
                <aura:iteration items="{!v.accounts}" var="account">
                    <tr class="slds-hint-parent">
                        <td class="" data-label="Action" style="padding-left:0;">
                            <ui:inputCheckbox label="" class="check" text="{!account.Id}" aura:id="dependent"/>
                        </td>
                        <td class="" data-label="Account Name" style="padding-left:0;">
                            <a href="{! '#/sObject/' + account.Id + '/view'}">{!account.Name}</a>
                        </td>                                 
                    </tr>
                </aura:iteration>
            </tbody>
        </table>
<aura:component>
</pre>
This is the client side controller:
<pre>
getAccount : function(component,event,helper) {
        var action=component.get("c.getAccountList");
        action.setCallback(this, function(a) {
            component.set("v.accounts", a.getReturnValue());
        });
        $A.enqueueAction(action);
    },
checkAll:function(component,event,helper){
        var master= component.find("master");
        var dep= component.find("dependent");
        var val= master.get("v.value");
        if(val==true){
            for(var i=0;i<dep.length;i++){
                dep[i].set("v.value",true);
            }
        }else{
           for(var i=0;i<dep.length;i++){
                dep[i].set("v.value",false);
            }
        }
    },
    delete:function(cmp,evt,helper){}
</pre>
This is the sever side controller:
<pre>
public with sharing class AccountListController {
    @AuraEnabled
    public static List<Account> getAccountList() {
        return [SELECT Id,Name,Accountnumber FROM Account order by CreatedDate desc];
    }       
}
</pre>
Kindly help.
Thanks
Regards
 
Hi everyone,
i've to remove the component dynamically, here is my code:
<pre>
<!--DynamicComponent-->
<aura:component >
    <ltng:require styles="{!$Resource.SLDS +
             '/assets/styles/salesforce-lightning-design-system-ltng.css'}"/>
    <aura:handler name="removeComponent" action="{!c.removeComponent}" event="c:TestEvent"/>    
    <div class="wk_static">
        <button class="slds-button slds-button--neutral" onclick="{!c.getCompnent}">Open Modal</button>
        <div role="dialog" tabindex="-1" aura:id="Modalbox" aria-labelledby="header43" class="slds-modal ">
            <div class="slds-modal__container">
               <div class="slds-modal__header">
                    <button class="slds-button slds-button--icon-inverse slds-modal__close" onclick="{!c.removeComponent}">
                        <span>
                            <c:VehicleSVG class="slds-button__icon slds-button__icon--large" xlinkHref="/resource/SLDS/assets/icons/action-sprite/svg/symbols.svg#close" />
                            <span class="slds-assistive-text">Close</span>
                        </span>                    
                    </button>
                    <h2 id="header43" class="slds-text-heading--medium">Modal Header</h2>
                </div>
                {!v.body}        
                <div class="slds-modal__footer">
                    <button class="slds-button slds-button--neutral" onclick="{!c.removeComponent}">Cancel</button>
                    <button class="slds-button slds-button--neutral slds-button--brand" onclick="{!c.removeComponent}">Save</button>
                </div>
            </div>
        </div>
        <div class="slds-backdrop " aura:id="MB-Back"></div>
    </div>
</aura:component>
</pre>
Controller:
<pre>
({
    getCompnent: function(cmp,event) {
        $A.createComponent(
            "c:TestComponent",{},
            function(newcomponent){
                //Add the new button to the body array
                if (cmp.isValid()) {
                    var body = cmp.get("v.body");
                    body.push(newcomponent);
                    cmp.set("v.body", body);
                }
            }
        );
        var cmpTarget = cmp.find('Modalbox');
           var cmpBack = cmp.find('MB-Back');
        $A.util.addClass(cmpTarget, 'slds-fade-in-open');
        $A.util.addClass(cmpBack, 'slds-backdrop--open');
    },
    removeComponent: function(cmp,event){
        $A.createComponent(
            "c:TestComponent",{},
            function(newcomponent){
                //Add the new button to the body array
                if (cmp.isValid()) {
                    var body = cmp.get("v.body");
                    cmp.set("v.body",[]);
                }
            }
        );
        var cmpTarget = cmp.find('Modalbox');
           var cmpBack = cmp.find('MB-Back');
        $A.util.removeClass(cmpBack,'slds-backdrop--open');
        $A.util.removeClass(cmpTarget, 'slds-fade-in-open');
    }
})
</pre>
Test component:
<pre>
<aura:component >
     <ltng:require styles="{!$Resource.SLDS +
             '/assets/styles/salesforce-lightning-design-system-ltng.css'}"/>
    <aura:registerEvent name="removeComponent" type="c:TestEvent"/>
    <div class="wk_static">
        <div class="slds-modal__content slds-p-around--medium">
            <div>
                <p>Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. Mollit officia cillum Lorem ullamco minim nostrud elit officia tempor esse quis. Cillum sunt ad dolore
                quis aute consequat ipsum magna exercitation reprehenderit magna. Tempor cupidatat consequat elit dolor adipisicing.</p>
                <p>Dolor eiusmod sunt ex incididunt cillum quis nostrud velit duis sit officia. Lorem aliqua enim laboris do dolor eiusmod officia. Mollit incididunt nisi consectetur esse laborum eiusmod pariatur proident. Eiusmod et adipisicing culpa deserunt
                nostrud ad veniam nulla aute est. Labore esse esse cupidatat amet velit id elit consequat minim ullamco mollit enim excepteur ea.</p>
                <button class="slds-button slds-button--neutral" onclick="{!c.removeComponent}">Cancel</button><!--I've to remove component through this button-->
            </div>
        </div>
    </div>
</aura:component>
</pre>
controller:
<pre>
({
    removeComponent : function(component, event, helper) {
        var evt = component.getEvent("removeComponent");
        evt.fire();
    }
})
</pre>
Can anyone help,
Thanx in advance.
Hello Everyone,

my code is:
component1:
<aura:component>
    <aura:registerEvent name="createRecord" type="c:Event"/>
    <ui:button action={!c.createRecord}>Create Record</ui:button>
    <c:form/>
</aura:component>
controller1:
createRecord:function(cmp,event){
    var evt = cmp.getEvent("createRecord");
    evt.fire();
}
form-
<aura:component controller="saveRecord">
    <aura:attribute name="account" type="Account[]"/>
    <aura:handler name="createRecord" action="{!c.createRecord}" event="c:Event"/>
    <aura:attribute name="newAccount" type="Account"
         default="{ 'sobjectType': 'Account',
                         'Name': '',
                         'AccountNumber': '',
                         'AccountSource':'',
                         'Active__c': '',
                       }"/>
    <ui:inputText aura:id="Name" label="Account Name"  value="{!v.newAccount.Name}" required="true"/>
    <ui:inputText label="Account Name"  value="{!v.newAccount.accountNumber}"/>
    <ui:inputText label="Account Name"  value="{!v.newAccount.accountSource}" />
    <ui:inputText label="Account Name"  value="{!v.newAccount.Active__c}"/>
</aura:component>
form controller-
 createRecord : function(component, event, helper) {
        var accField = component.find("Name");
        var acc = accField.get("v.value");
        if (acc==''){
            accField.set("v.errors", [{message:"Enter account name."}]);
        }
        else {
            accField.set("v.errors", null);
            var newAccount = component.get("v.newAccount");
            helper.createRecord(component, newAccount);
        }
    }
form helper-
createrecord:function(cmp,event,callback){
var action = component.get("c.saveAccount");
        action.setParams({
            "account": account
        });
        if (callback) {
          action.setCallback(this, callback);
        }
        $A.enqueueAction(action);
}
I'm not able to create any record on click of the button, how will it be possible?
Thanks in advance
Hi all,
How can i rerender a list on adding a record through popup which is a component itself?
Thanks in advance.
Hello,
I have to access aura:id of a div in component through a button in  nested componet.
Can anyone help me with this??
Thanks
Hello Everyone,
I would like to know about creating popup/modal through lightning component.
Thanks
Regards

 
Hello Everyone,

Is there any way we can set min/max in ui:inputnumber tag, as we do in
<input type= "number" min="0" max="10"/>

Please reply
Thanks
Hello,

I've to write test class for the mentioned class.

Extention:
public with sharing class contactext {
    
    public contact con;
    
    public contactext(ApexPages.StandardController std){
        
            con = (contact)std.getrecord();
            
    }
    
    public pagereference savedata(){
    
        try{
        
            insert con;
            apexpages.addmessage(new apexpages.Message(apexpages.severity.confirm,'Contact Saved'));
        
        }catch(exception e){
        
            apexpages.addMessages(e);
        
        }
        
        pagereference pg = page.Task02_Contactext;
        pg.setredirect(true);
    
        return pg;
    
    }    
    
}

Can Anyone help??

Thanks
Regards


 
Hello,

On including bootstrap files in vf pages the page css is also getting affected, how can i prevent that?

Thank You
Regards
Hi guys,
What is Exactly Difference between Profile and Filed Level Security?
can anyone tel me.
Adv
Thanks & Regards
Hello everyone,
Is there any way to pass the value of an input text field in the vf page to lightning component, through a shared controller??

Thank You
Aakanksha Singh
Hi, 

I want to display list of accounts with contacts in lightning page. Here the code i have written. Here accounts are displaying but contacts are not display. Please help me to display the accounts with contacts.

Thank you.


 
<aura:component controller="accountsWithContactsClass" implements="flexipage:availableForAllPageTypes" access="global">
	 
    <aura:attribute name="accounts" type="Account[]" />
    <ui:button label="click this" press="{!c.myAction}" />
    <table>
            <tr><td><b>Name</b></td><td><b>Industry</b></td></tr>

    <aura:iteration items="{!v.accounts}" var="accs1" >
        <tr>   
        <td> {!accs1.Name}  </td>
         
      <td>   {!accs1.Industry}  </td> 
      <!--   <td>   {!accs1.Contacts.lastName}  </td> -->
        </tr>     
     <tr>   <aura:iteration items="{!v.accs1.contacts}" var="con1" >
            
             <td>{!con1.lastName} </td>
            
        </aura:iteration></tr>
     </aura:iteration>                                            
        </table>
    
</aura:component>








({
	myAction : function(component, event, helper) {
		var action =component.get("c.getAllAccounts");
        console.log('The action value is: '+action);
         action.setCallback(this, function(a){ 
             
            component.set("v.accounts", a.getReturnValue());
           //  console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
            console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
          
        });
        $A.enqueueAction(action);
	}
})











public class accountsWithContactsClass {

@auraEnabled
public static list<account> getAllAccounts()
    {
       list<account> accs =[select id,name,phone,industry,(select lastName from contacts) from account limit 10];
      //  list<account> accs =[select id,name,phone,industry from account limit 10];
     //   return [select Id,Name from account limit 10];
     return accs;
    }
}

 
Hello Everyone,
I want to know how can we reload an iframe which contains a visualforce page,so that the value in visualforce page could be updated, through a button in lightning component.
P.S.- I don't have any code regarding it.
Thanks
Regards
Hello everyone,
I need to know how can I perform mass delete operation with the use of checkboxes.
Here is my component.
<pre>
<aura:component implements="force:appHostable" controller="AccountListController">
<aura:attribute name="accounts" type="Account[]"/>
<aura:handler name="init" value="{!this}" action="{!c.getAccount}" />
<ui:button class="slds-button slds-button--destructive" press="{!c.delete}">Delete</ui:button><!--Mass Delete operation-->
<table class="slds-table slds-table--bordered slds-max-medium-table--stacked-horizontal">
            <thead>
                <tr class="slds-text-heading--label ">
                    <th class="slds-is-sortable" scope="col">
                        <ui:inputCheckbox label="" class="check" aura:id="master" click="{!c.checkAll}"/>
                        Action                        
                    </th>
                    <th class="" scope="col">Account Name</th>
                </tr>  
            </thead>
            <tbody>
                <aura:iteration items="{!v.accounts}" var="account">
                    <tr class="slds-hint-parent">
                        <td class="" data-label="Action" style="padding-left:0;">
                            <ui:inputCheckbox label="" class="check" text="{!account.Id}" aura:id="dependent"/>
                        </td>
                        <td class="" data-label="Account Name" style="padding-left:0;">
                            <a href="{! '#/sObject/' + account.Id + '/view'}">{!account.Name}</a>
                        </td>                                 
                    </tr>
                </aura:iteration>
            </tbody>
        </table>
<aura:component>
</pre>
This is the client side controller:
<pre>
getAccount : function(component,event,helper) {
        var action=component.get("c.getAccountList");
        action.setCallback(this, function(a) {
            component.set("v.accounts", a.getReturnValue());
        });
        $A.enqueueAction(action);
    },
checkAll:function(component,event,helper){
        var master= component.find("master");
        var dep= component.find("dependent");
        var val= master.get("v.value");
        if(val==true){
            for(var i=0;i<dep.length;i++){
                dep[i].set("v.value",true);
            }
        }else{
           for(var i=0;i<dep.length;i++){
                dep[i].set("v.value",false);
            }
        }
    },
    delete:function(cmp,evt,helper){}
</pre>
This is the sever side controller:
<pre>
public with sharing class AccountListController {
    @AuraEnabled
    public static List<Account> getAccountList() {
        return [SELECT Id,Name,Accountnumber FROM Account order by CreatedDate desc];
    }       
}
</pre>
Kindly help.
Thanks
Regards
 
Hi everyone,
i've to remove the component dynamically, here is my code:
<pre>
<!--DynamicComponent-->
<aura:component >
    <ltng:require styles="{!$Resource.SLDS +
             '/assets/styles/salesforce-lightning-design-system-ltng.css'}"/>
    <aura:handler name="removeComponent" action="{!c.removeComponent}" event="c:TestEvent"/>    
    <div class="wk_static">
        <button class="slds-button slds-button--neutral" onclick="{!c.getCompnent}">Open Modal</button>
        <div role="dialog" tabindex="-1" aura:id="Modalbox" aria-labelledby="header43" class="slds-modal ">
            <div class="slds-modal__container">
               <div class="slds-modal__header">
                    <button class="slds-button slds-button--icon-inverse slds-modal__close" onclick="{!c.removeComponent}">
                        <span>
                            <c:VehicleSVG class="slds-button__icon slds-button__icon--large" xlinkHref="/resource/SLDS/assets/icons/action-sprite/svg/symbols.svg#close" />
                            <span class="slds-assistive-text">Close</span>
                        </span>                    
                    </button>
                    <h2 id="header43" class="slds-text-heading--medium">Modal Header</h2>
                </div>
                {!v.body}        
                <div class="slds-modal__footer">
                    <button class="slds-button slds-button--neutral" onclick="{!c.removeComponent}">Cancel</button>
                    <button class="slds-button slds-button--neutral slds-button--brand" onclick="{!c.removeComponent}">Save</button>
                </div>
            </div>
        </div>
        <div class="slds-backdrop " aura:id="MB-Back"></div>
    </div>
</aura:component>
</pre>
Controller:
<pre>
({
    getCompnent: function(cmp,event) {
        $A.createComponent(
            "c:TestComponent",{},
            function(newcomponent){
                //Add the new button to the body array
                if (cmp.isValid()) {
                    var body = cmp.get("v.body");
                    body.push(newcomponent);
                    cmp.set("v.body", body);
                }
            }
        );
        var cmpTarget = cmp.find('Modalbox');
           var cmpBack = cmp.find('MB-Back');
        $A.util.addClass(cmpTarget, 'slds-fade-in-open');
        $A.util.addClass(cmpBack, 'slds-backdrop--open');
    },
    removeComponent: function(cmp,event){
        $A.createComponent(
            "c:TestComponent",{},
            function(newcomponent){
                //Add the new button to the body array
                if (cmp.isValid()) {
                    var body = cmp.get("v.body");
                    cmp.set("v.body",[]);
                }
            }
        );
        var cmpTarget = cmp.find('Modalbox');
           var cmpBack = cmp.find('MB-Back');
        $A.util.removeClass(cmpBack,'slds-backdrop--open');
        $A.util.removeClass(cmpTarget, 'slds-fade-in-open');
    }
})
</pre>
Test component:
<pre>
<aura:component >
     <ltng:require styles="{!$Resource.SLDS +
             '/assets/styles/salesforce-lightning-design-system-ltng.css'}"/>
    <aura:registerEvent name="removeComponent" type="c:TestEvent"/>
    <div class="wk_static">
        <div class="slds-modal__content slds-p-around--medium">
            <div>
                <p>Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. Mollit officia cillum Lorem ullamco minim nostrud elit officia tempor esse quis. Cillum sunt ad dolore
                quis aute consequat ipsum magna exercitation reprehenderit magna. Tempor cupidatat consequat elit dolor adipisicing.</p>
                <p>Dolor eiusmod sunt ex incididunt cillum quis nostrud velit duis sit officia. Lorem aliqua enim laboris do dolor eiusmod officia. Mollit incididunt nisi consectetur esse laborum eiusmod pariatur proident. Eiusmod et adipisicing culpa deserunt
                nostrud ad veniam nulla aute est. Labore esse esse cupidatat amet velit id elit consequat minim ullamco mollit enim excepteur ea.</p>
                <button class="slds-button slds-button--neutral" onclick="{!c.removeComponent}">Cancel</button><!--I've to remove component through this button-->
            </div>
        </div>
    </div>
</aura:component>
</pre>
controller:
<pre>
({
    removeComponent : function(component, event, helper) {
        var evt = component.getEvent("removeComponent");
        evt.fire();
    }
})
</pre>
Can anyone help,
Thanx in advance.