• tulasiram ch
  • NEWBIE
  • 225 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 60
    Questions
  • 66
    Replies
Child component is working fine , but  unable to pass parentid to child component. Please help me
Parent component:
  1. <aura:component controller="accountsWithContactsClass" implements="flexipage:availableForAllPageTypes,force:hasRecordId,force:appHostable" access="global" >
  2.       <aura:attribute name="accounts" type="account[]"/>    
  3.     <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
  4.      <aura:attribute name="selectedId" type="string"/>
  5.     <aura:attribute name="isTrue" type="account" default="false"/>
  6.    <table class="slds-table slds-table--bordered">
  7.         <tr>
  8.             <td> Name </td>
  9.             <td> Industry </td>
  10.             <td> Phone</td>
  11.             <td> CreatedDate</td>
  12.             <td> ContactList Button</td>
  13.          </tr> <b/>
  14.          <aura:iteration items="{!v.accounts}" var="accs1" >
  15.                <tr>
  16.                 <td> {!accs1.Name} </td>
  17.                 <td> {!accs1.Industry} </td>
  18.                 <td> {!accs1.Phone} </td>
  19.                 <td> {!accs1.CreatedDate}</td>
  20.                 <td> 
  21.                     <lightning:button value="{!accs1.Id}" variant="neutral" label="ContactList" onclick="{! c.handleClick }" /> 
  22.                   
  23.                    </td>
  24.                </tr><b/>
  25.          </aura:iteration>
  26.     </table >
  27.    <c:DisplayAccountswithContactsNested1 aura:id="compB" selectedAccount="{!v.selectedId}"/>
  28.    
  29. </aura:component>
Parent Controller:
  1. ({
  2.  
  3.  
  4.     doInit : function(component, event, helper) {
  5.         
  6.         var action =component.get("c.getAllAccounts");
  7.         console.log('The action value is: '+action);
  8.        
  9.         action.setCallback(this, function(a){ 
  10.  
  11.             component.set("v.accounts", a.getReturnValue());
  12.            //  console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
  13.             console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
  14.  
  15.         });
  16.         $A.enqueueAction(action);
  17.     },
  18.    
  19.     handleClick : function(component, event, helper) {
  20.         var accId = event.getSource().get("v.value");
  21.         component.set("v.selectedId",accId);
  22.        
  23.     },
  24. })
Child component:
  1. <aura:component controller="accountsWithContactsClass" implements="flexipage:availableForAllPageTypes,force:hasRecordId,force:appHostable" access="global" >
  2.      <aura:attribute name="selectedAccount" type="string" />
  3.     <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
  4.    <aura:attribute name="contacts" type="contact[]"/> 
  5.    
  6.     <aura:attribute name="isOpen" type="boolean" default="false"/>
  7.     <aura:attribute name="showSpinner" type="boolean" default="false"/>
  8.     <div class="slds-m-around--xx-large">
  9.         <lightning:spinner variant="brand" size="large" class="{!if(v.showSpinner,'slds-show','slds-hide')}"/>
  10.         <aura:if isTrue="{!v.isOpen}">
  11.         <div class="demo-only" style="height: 640px;">
  12.              <div role="dialog" tabindex="-1" class="slds-modal slds-fade-in-open slds-modal_large slds-list-builder" aria-labelledby="id-of-modalheader-h2" aria-modal="true" aria-describedby="modal-content-id-1">
  13.                  <div class="slds-modal__container">
  14.                      <div class="slds-modal__header" >
  15.                         <p class="conList">Contact List</p> 
  16.                                 </div>
  17.  
  18.                              <div class="slds-modal__content slds-p-around_medium" > 
  19.                                 <table class="slds-table slds-table--bordered"   >
  20.                                    <thead>
  21.                                         <tr class="slds-text-heading--label">
  22.                                           <th class="slds-cell-shrink">
  23.                                             <label class="slds-checkbox">
  24.                                               <input type="checkbox" name="options" />
  25.                                               <span class="slds-checkbox--faux"></span>
  26.                                               <span class="slds-assistive-text">Select All</span>
  27.                                             </label>
  28.                                           </th>
  29.                                         
  30.                                         
  31.                                         <td>ContacFirstName</td>
  32.                                         <td>Phone</td>
  33.                                         <td>CreatedDate</td>
  34.                                     </tr>
  35.                                   </thead>
  36.                                  <aura:iteration items="{!v.contacts}" var="cons" >
  37.                                   <tbody>
  38.                                    <tr class="slds-hint-parent">
  39.                                       <td class="slds-cell-shrink" data-label="Select Row">
  40.                                         <label class="slds-checkbox">
  41.                                           <input type="checkbox" name="options" />
  42.                                           <span class="slds-checkbox--faux"></span>
  43.                                           <span class="slds-assistive-text">Select Row</span>
  44.                                         </label>
  45.                                       </td>
  46.                                      <td>                               
  47.                                         <a  
  48.                                         href="{!'/one/one.app?#/sObject/'+ cons.Id + '/view'}" 
  49.                                         target="_blank">
  50.                                        {!cons.FirstName}
  51.                                       </a>
  52.                                       </td>
  53.                                       <td> {!cons.Email} </td>
  54.                                       <td> {!cons.Phone} </td>
  55.                                       <td> {!cons.CreatedDate}</td>
  56.                                      </tr>
  57.                                      </tbody>
  58.                                   </aura:iteration>
  59.                                       
  60.                                 </table>
  61.                              </div>
  62.  
  63.                               <div class="slds-modal__footer">
  64.                                <lightning:button variant="neutral" label="Close" onclick="{! c.closeModel }"/> 
  65.                                <lightning:button variant="neutral" label="LikenClose" onclick="{! c.likenClose }" />
  66.                               </div>
  67.                              </div>
  68.  
  69.                      </div>
  70.                    </div>
  71.                     <div class="slds-backdrop slds-backdrop_open"></div>
  72.                 </aura:if>
  73.  
  74.          </div>
  75. </aura:component>
Child Controller:
  1. ({
  2.     doInit : function(component, event, helper) {
  3.       component.set("v.showSpinner",true);
  4.         var accId = component.get("v.selectedAccount");
  5.         var action = component.get("c.getAllContacts");
  6.         action.setParams({
  7.             "ParentId": accId
  8.         });
  9.         action.setCallback(this, function(response){
  10.             var state = response.getState();
  11.             if (component.isValid() && state === "SUCCESS"){
  12.                 $A.log(response);
  13.                 component.set("v.contacts", response.getReturnValue());
  14.             }
  15.             else {
  16.                 console.log("Failed with state" + state);
  17.             }
  18.             component.set("v.showSpinner",false);
  19.         })
  20.         $A.enqueueAction(action);
  21.         component.set("v.isOpen", true);   // for Hide/Close Model,set the "isOpen" attribute to "Fasle" 
  22.     },
  23.     closeModel: function(component, event, helper) {
  24.         component.set("v.isOpen", false); // for Hide/Close Model,set the "isOpen" attribute to "Fasle"  
  25.         
  26.     },
  27.     likenClose: function(component, event, helper) {
  28.         alert('thanks for like Us :)');// Display alert message on the click on the "Like and Close" button from Model Footer 
  29.         // and set set the "isOpen" attribute to "False for close the model Box.
  30.         component.set("v.isOpen", false);
  31.     },
  32.     
  33. })
application:
  1. <aura:application extends="force:slds" >   
  2.     
  3.     <!--<c:DisplayAccountswithContactsNested1 selectedAccount="0012800000C7F3zAAF"/> -->
  4.     <c:displayAccountsWithContacts />
  5. </aura:application>
  6.  
  7. Apex class:
  8. public class accountsWithContactsClass {
  9.     @auraEnabled
  10.     public static list<account> getAllAccounts()
  11.     {
  12.      list<account> accs =[select id,name,phone,industry,CreatedDate from account limit 10];
  13.      return accs;
  14.     }
  15.     @auraEnabled
  16.     public static list<contact> getAllContacts(String ParentId)
  17.         {
  18.          list<contact> cons = [select id,firstname,phone,CreatedDate,Email,accountid,account.name from contact where accountid =: ParentId];
  19.          return cons;
  20.         }
  21. }
Please help me out from this........
 
I used following component and controller with apex class: But i am knew to lightning, Please help me how to display related contactlist with accountid in new window...
DisplayAccountsWithContacts.cmp:
  1. <aura:component controller="accountsWithContactsClass" implements="flexipage:availableForAllPageTypes" access="global">
  2.    <aura:handler name="init" value="{!this}" action="{!c.myAction}"/>
  3.    <aura:attribute name="accounts" type="account[]"/>
  4.    <table>
  5.         <tr>
  6.             <td> Name </td>
  7.             <td> Industry </td>
  8.             <td> Phone</td>
  9.             <td> CreatedDate</td>
  10.             <td> ContactList Button</td>
  11.          </tr> <b/>
  12.          <aura:iteration items="{!v.accounts}" var="accs1" >
  13.                <tr>
  14.                 <td> {!accs1.Name} </td>
  15.                 <td> {!accs1.Industry} </td>
  16.                 <td> {!accs1.Phone} </td>
  17.                 <td> {!accs1.CreatedDate}</td>
  18.                 <td> <lightning:button variant="neutral" label="ContactList" onclick="{! c.handleClick }" /> 
  19.                    </td>
  20.                </tr><b/>
  21.          </aura:iteration>
  22.     </table>
  23.     <aura:attribute name="isOpen" type="boolean" default="false"/>
  24.          <div class="slds-m-around--xx-large">
  25.                 <aura:if isTrue="{!v.isOpen}">
  26.                  <div role="dialog" tabindex="-1" aria-labelledby="header99" class="slds-modal slds-fade-in-open ">
  27.                     <div class="slds-modal__container">
  28.                   <!-- ###### MODAL BOX HEADER Part Start From Here ######-->
  29.                       <div class="slds-modal__header">
  30.                     <button class="slds-button slds-modal__close slds-button--icon-inverse" title="Close" onclick="{!c.closeModel}">
  31.                     <span class="slds-assistive-text">Close</span>
  32.                     </button>
  33.                     <h2 id="header99" class="slds-text-heading--medium">ContactList</h2>
  34.                   <!--###### MODAL BOX FOOTER Part Start From Here ######-->
  35.                       <div class="slds-modal__footer">
  36.                         <button class="slds-button slds-button--neutral" onclick="{!c.closeModel}" >Cancel</button>
  37.                         <button class="slds-button slds-button--brand" onclick="{!c.likenClose}">Like and Close</button>
  38.                       </div>
  39.                       </div>
  40.                             
  41.                     </div>
  42.                    </div>
  43.                 </aura:if>
  44.          </div>
  45. </aura:component>
DisplayAccountsWithContactsController.js:
  1. ({    
  2.     myAction : function(component, event, helper) {
  3.         var action =component.get("c.getAllAccounts");
  4.         console.log('The action value is: '+action);
  5.          action.setCallback(this, function(a){              
  6.             component.set("v.accounts", a.getReturnValue());
  7.            //  console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
  8.             console.log('The accs are :'+JSON.stringify(a.getReturnValue()));          
  9.         });
  10.         $A.enqueueAction(action);
  11.     },
  12.     handleClick : function(component, event, helper) { 
  13.         component.set("v.isOpen", true);   // for Hide/Close Model,set the "isOpen" attribute to "Fasle" 
  14.     }  , 
  15.       closeModel: function(component, event, helper) {
  16.          component.set("v.isOpen", false); // for Hide/Close Model,set the "isOpen" attribute to "Fasle"        
  17.    },
  18.    likenClose: function(component, event, helper) {
  19.         alert('thanks for like Us :)');// Display alert message on the click on the "Like and Close" button from Model Footer 
  20.                                        // and set set the "isOpen" attribute to "False for close the model Box.
  21.         component.set("v.isOpen", false);
  22.    },
  23. })
accountswithContactsClass.apxc:
public class accountsWithContactsClass {
    @auraEnabled
public static list<account> getAllAccounts()
    {
     list<account> accs =[select id,name,phone,industry,CreatedDate from account limit 10];
     return accs;
    }
}
===================================================================================================
User-added image











 
App:
  1. <aura:application  access="global" extends="ltng:outApp">
  2.     <aura:dependency resource="c:flipCard" />
  3.     
  4. </aura:application>
component:
  1. <aura:component >
  2.     <aura:attribute type="string" name="bgColor" />
  3.     <aura:attribute type="string" name="fontColor" default="#000"/>
  4.     <aura:attribute type="string" name="borderColor" default="#000"/>
  5.     <aura:attribute type="string" name="frontText" />
  6.     <aura:attribute type="string" name="backText" /> 
  7.     <aura:attribute type="boolean" name="isVerticalFlip" default="false" description="By default its Horizontal flip" />
  8. <div class="{! 'slds flip-container ' + (v.isVerticalFlip == false ? 'horizontal' : 'vertical') }" style="{! 'background-color:'+ v.bgColor+'; color: '+ v.fontColor+';border : 1px solid '+ v.borderColor}">
  9. <div class="flipper">
  10. <div class="front">
  11.                 {!v.frontText}
  12.             </div>
  13. <div class="back">
  14.                 {!v.backText}
  15.             </div>
  16.         </div>
  17.     </div>
  18. </aura:component>
Css:
  1. .slds.THIS{
  2.     padding : 10px;
  3.     margin : 10px; 
  4.     display: inline-block;
  5.     border-radius: 15px;
  6.     text-align: center;
  7.     font-size : 2em;
  8.  
  9. .THIS .flip-container {
  10.     perspective: 1000px;
  11. /* hide back while swapping*/
  12. .THIS .front, .THIS .back {
  13.     backface-visibility: hidden; 
  14.     position: absolute;
  15.     top: 0;
  16.     left: 0;
  17. }
  18.  
  19. .THIS.flip-container, .THIS .front, .THIS .back {
  20.     width: 100%;
  21.     height: 100%;
  22. }
  23. .THIS .front {
  24.     z-index: 2;  
  25. }
  26.  
  27. /* Flip Speed */
  28. .THIS .flipper {
  29.     transition: 0.6s;
  30.     transform-style: preserve-3d; 
  31.     position: relative; 
  32.  
  33. .THIS.flip-container.horizontal:hover .flipper, .THIS.flip-container.horizontal.hover .flipper {
  34.         transform: rotateY(180deg);
  35. }
  36.  
  37. .THIS.horizontal .front { 
  38.     transform: rotateY(0deg);
  39. }
  40.  
  41. /* back, initially hidden pane */
  42. .THIS.horizontal .back {
  43.     transform: rotateY(180deg);
  44. }
  45.  
  46. .THIS.flip-container.vertical:hover .flipper, .THIS.flip-container.vertical.hover .flipper {
  47.         transform: rotateX(180deg);
  48. }
  49.  
  50. .THIS.vertical .front { 
  51.     transform: rotateX(0deg);
  52. }
  53.  
  54. /* back, initially hidden pane */
  55. .THIS.vertical .back {
  56.     transform: rotateX(180deg);
  57. }
VF page:
  1. <apex:page >
  2.     <apex:includeLightning />
  3.     <div style="width:50%;height:150px;" id="flipCardId" />
  4.     <script>
  5.     $Lightning.use("c:lightningOutAppContainer",
  6.                    function(){
  7.                    $Lightning.createComponent("c:flipCard",
  8.                           {
  9.                               borderColor: "green",
  10.                               bgColor:"white",
  11.                               fontColor:"red",
  12.                               frontText:"What is a cool about Lightning Component Development",
  13.                               backText:"You do not need to enable Lightning experience, it will work on Classic instance as well"
  14.                          },
  15.                              "flipCardId",
  16.                                function(cmp){
  17.                                console.log('Component created, do something cool here')
  18.                                });
  19.                    });
  20.     </script>
  21. </apex:page>
please help me, why background color of a flipcard is not working.
AccountListComponent.cmp:
  1. <aura:component controller="AccountListController">
  2.     <aura:attribute name="Accounts" type="account[]"/>
  3.     <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
  4.     <aura:iteration items="{!v.Accounts}" var="acc">
  5.         <ui:outputText value="{!acc.name}"/>
  6.     </aura:iteration>
  7. </aura:component>
AccountListComponentController.js:
  1. ({
  2.     doInit : function(component, event, helper) {
  3.         var action = component.get("c.getAccounts");
  4.         
  5.         action.setCallback(this, function(response){
  6.             var state = response.getState();
  7.             $A.log(response);
  8.             if(state == "SUCCESS"){
  9.                 component.set("v.Accounts", response.getReturnValue());
  10.             }
  11.         });
  12.         $A.enqueueAction(action);
  13.     }
  14. })
AccountListController.apxc:
  1. public class AccountListController {
  2.     @AuraEnabled
  3.     public static List<account> getAccounts(){
  4.        list<account> accs =[select id,name from account];
  5.      return accs;
  6.     }
  7. }
harnessApp.app:
  1. <aura:application >
  2.     <div style="height: 400px;overflow: scroll; padding-top: 10px;">
  3.     <c:AccountListComponent />
  4.     </div>
  5. </aura:application>
Please give me a solution.
harnessApp.app:
  1. <aura:application >
  2.     <c:campingListItem item="{!v.a0d2800000DTLYOAA5}"/>
  3. </aura:application>
campingListItem.cmp:
  1. <aura:component >
  2.     <aura:attribute name="item" type="Camping_Item__c" required="true"/>
  3.     <p> The Item is <ui:outputText value="{!v.item}"></ui:outputText></p>
  4.     <p>Name:<ui:outputText value="{!v.item.Name}" />  </p>
  5.     <p>Price: <ui:outputCurrency value="{!v.item.Price__c}" /> </p>
  6.     <p>Quantity:<ui:outputNumber value="{!v.item.Quantity__c}" /> </p>
  7.     <p>Packed:<ui:outputCheckbox value="{!v.item.Packed__c}" />  </p>
  8.    <div><ui:button label="Packed!" press="{!c.packItem}"/>
  9.    </div>
  10. </aura:component>
harnessAppController.js:
  1. ({
  2.      packItem: function(component, event, helper) {
  3.         var btn= event.getSource();
  4.         var BtnMessage =btn.get("v.label");
  5.         component.set("v.item",BtnMessage);
  6.         var btnClicked = event.getSource();
  7.         btnClicked.set("v.disabled",true);     
  8.      }
  9. })
User-added imageUser-added image
But i am getting above error when click on the button packed!.....
i used below code for--- when i was created a record1 in Org1, it will automatically created in Org2.
org1:
1. i used trigger to pass new record id's to the webservice calss below.
2.webservice class:
  1. public class deserializeResponse{
  2.         public string id;
  3.         public string access_token;
  4.     }
  5.     public string ReturnAccessToken(sendAccountsToWebservice account){
  6.         system.debug('entered accestoken methd');
  7.       String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
  8.       Http h = new Http();
  9.       HttpRequest req = new HttpRequest();
  10.       req.setBody(reqbody);
  11.       req.setMethod('POST');
  12.       req.setEndpoint('https://ap5.salesforce.com/services/oauth2/token');
  13.  
  14.       HttpResponse res = h.send(req);
  15.  
  16.       deserializeResponse resp1 = (deserializeResponse)JSON.deserialize(res.getbody(),deserializeResponse.class);
  17.  
  18.       return resp1.access_token;
  19.     }
  20.     @future(callout=true)
  21.     public static void makePostCallout(set<id> accIds){
  22.         
  23.           String str;
  24.         List<Account> accList = [select Name,Website from Account where Id IN :accIds];
  25.        
  26.         sendAccountsToWebservice acount1 = new sendAccountsToWebservice();
  27.         String accesstoken;
  28.         accesstoken = acount1.ReturnAccessToken(acount1);
  29.         
  30.         JSONGenerator gen = JSON.createGenerator(true);
  31.             gen.writeStartObject();  
  32.             gen.writeFieldName('Accounts');
  33.  
  34.             gen.writeStartArray();
  35.             for(Account a : accList)
  36.             {
  37.                 gen.writeStartObject();
  38.                     gen.writeStringField('Name', a.Name);
  39.                     gen.writeStringField('Website', a.Website);
  40.                     gen.writeStringField('Id', a.id);
  41.                 gen.writeEndObject();
  42.     
  43.             }
  44.             
  45.             gen.writeEndArray();
  46.          gen.writeEndObject();
  47.  
  48. str = gen.getAsString();
  49.  
  50.   
  51.         //json ends
  52.         if(accesstoken!=null)
  53.         {
  54.         system.debug('AT not null');
  55.             
  56.             Http http = new Http();
  57.             HttpRequest request = new HttpRequest();
  58.             request.setEndpoint('https://ap5.salesforce.com/services/apexrest/createAccounts/');
  59.             
  60.             request.setMethod('POST');
  61.             request.setHeader('Authorization','Bearer '+accesstoken);
  62.             request.setHeader('Content-Type','application/json');
  63.  
  64.             request.setHeader('accept','application/json');
  65.  
  66.             request.setBody(str);
  67.             
  68.             system.debug('JS'+str);
  69.             
  70.              system.debug('REQ BODY'+request.getBody());
  71.             
  72.            
  73.              HttpResponse response = http.send(request);
  74.                         
  75.                         system.debug('RESPONSE BODY'+response.getBody());
  76.                         Map<String,String> Org1Org2Map = new Map<String,String>();
  77.                     
  78.              // myVar.bool = false;
  79.              update accList; 
  80.                        
  81.         }
  82.     }   
I used username and password for establishing the connection between two orgs in the above webservice:

Org2: 
@RestResource(urlmapping='/createAccounts/*')
global with sharing class AccountsManager {     
 @HttpPost     global static void createAccounts(List<Account> Accounts)     {       
  List<Id> accIds = new List<Id>();        
 List<Account> accList = new List<Account>();                      .
for(Account a1 : Accounts)       {           
Account a = new Account();           
a.Name = a1.Name;         
a.Website = a1.Website;           
a.Org1__c = a1.Id;           
accList.add(a);       }          
insert accList;                 
 Map<String,String> Org1Org2Map = new Map<String,String>();         
for(Account a : accList)         {             
Org1Org2Map.put(a.Org1__c,a.id);        
 }         
system.debug('ORGS MAP'+Org1Org2Map);                  
RestContext.response.responsebody = Blob.valueOf(JSON.serialize(Org1Org2Map));
             }    
 }
i want to get back the response to org1 when the record inserted in Org2, based on that response i want to update a field on the object in the org1.
how can i achieve that. and how can i write test class for this. i refered some docs for writing test classes for web services but i didn't understand those. please help i am new to integration. Thank you!
Below is the code how can we write test class for this page with controller. Please help me
<apex:page controller="listViewsForContactRecords">
<apex:form >
            <apex:pageBlock >
           
            <apex:pageBlockTable value="{!accountsToDisplay}" var="acc" columns="2" id="pgtparent">
            <apex:column headerValue="AccountName" >
            <apex:commandLink value="{!acc.name}" action="{!MethodToCall}" rerender="pgbContacts" status="status">
            <apex:param value="{!acc.Id}" name="idForConts" assignTo="{!recid}"/>
            </apex:commandLink>
            </apex:column>
            <apex:column value="{!acc.Phone}"/>
            </apex:pageblockTable>
            </apex:pageBlock> 
    <apex:pageBlock title="Account Related Contacts"> 
       
    <apex:outputPanel id="pgbContacts">
    <apex:actionStatus startText="Please Wait Loading..." stopText="" id="status"></apex:actionStatus>
    <apex:pageblockTable value="{!conList }" var="cons">
    <apex:column headerValue="FirstName">
    <apex:inputText value="{!cons.FirstName}"/>
    </apex:column>
    <apex:column headerValue="LastName">
    <apex:inputText value="{!cons.LastName}"/>
    </apex:column>
    <apex:column >
    <apex:commandButton value="EditContact"/>
    </apex:column>
    </apex:pageblockTable>
    </apex:outputPanel> 
    </apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class listViewsForContactRecords {

    public list<contact> conList{get;set;}
    public string recid{get;set;}

    set<id> accIds = new set<id>();
    public list<account> accountsToDisplay{get;set;}
    public account getAcounts() {
        return null;
    }

public listViewsForContactRecords(){
accountsToDisplay = [select id, name, phone from account limit 10];

}
 public void MethodToCall() {
        conList = [select id, FirstName, LastName from contact where accountid=:recid];

    }
}
if birt date of contact is 30th august , how can we send wishes alert to the contact  at 29th august 11:55pm.

​How can we achieve this please help me.
Hi i used below code but its not working fine
1. Only one account record is displaying in first page
2.Popup window is not closing after record update or cancel.

Below is my code:
Page1:
<apex:page standardController="Account" recordSetVar="accs">
<script>
  function OpenVfpage(pid){
      var newwindow = window.open('/apex/Accsmallpopup?id='+pid, 'name=_blank','height=500,width=500,left=250,top=100'); 
  newwindow.focus();
 }
</script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!accs}" var="a" >
                <apex:column value="{!a.Id}"/>
                <apex:column value="{!a.name}"/>
                <apex:column value="{!a.Phone}"/>
                <apex:column value="{!a.Industry}"/>
                <apex:column id="two">
                    <apex:commandButton value="Click" onclick="OpenVfpage('{!a.id}')" reRender="two"/>
               </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Page2:
<apex:page controller="Accpopup2" showHeader="false" sidebar="false" id="the">
   <apex:form id="page">
    <apex:pageblock id="close">
    <apex:pageBlockSection >
        <apex:inputfield value="{!a.Name}"/>
         <apex:inputfield value="{!a.Phone}"/>
     </apex:pageBlockSection>
        <apex:pageblockbuttons >
        <apex:commandButton value="save" action="{!save}"/>
        <apex:commandButton value="cancel" action="{!cancel}"/>
            </apex:pageblockbuttons>
            <apex:inputHidden id="pass" value="{!status}"/>
             </apex:pageblock>
        
            <script language="JavaScript" type="text/javascript">
            if(document.getElementById('the:page:close:pass').getAttribute('value') == 'true')
                {
                    window.top.close();
                }
            </script>   
             </apex:form>
</apex:page>

Controller: 
public class Accpopup2 
{
    public Account a {get;set;}
    public string status {get;set;}
    public Accpopup2()
    {
      a = new account();  
    }
    public pagereference save()
    {
    ID caseID = apexpages.currentPage().getParameters().get('id');
    if(caseid!=null)
    {
        account acc = [select Name,Phone from account where ID =: caseID];
        acc.Name = a.Name;
        acc.Phone = a.Phone;
        update acc;
    }
       
        return null;
    }
    
    public pagereference cancel()
    {
        status = 'true';
          return null;    
    }
}
How can we achieve this:
1) visible the records of Opportunities for some users
if  Stage == open,
and
2) if Stage == closed only visible to sys admin and Manager .
I think it will be possible using Criteria based Object sharing rules through sharing settings. Is there any other approaches to fullfil this. Please help me out. Thank you!

global class batchForinsertingAccounts implements Database.Batchable<sObject>, Database.Stateful{
global integer count;
global string query;
global Database.QueryLocator start(Database.BatchableContext BC){
      count=0;
      return null;
}
global void execute(Database.BatchableContext BC, List<account> scope){
count=0;
list<Account> Llist = new list<Account>();
for(account acc:scope){
for(integer i=0;i<=20000 ;i++){
Account a = new account();
a.name = 'TulasiRam'+i;
Llist.add(acc);
count++;
}
}
database.insert(Llist);

}
global void finish(Database.BatchableContext BC){

system.debug(''+count);
}
}
Suppose user have default user resgistered with  email id like : user@gmail.com.
when an email alert initiated then user will get an email about update or any workflow action.
But user wants to get email alert only to his personal email which is not registered in  org, and email id like yyyyyyyyyyy@yahoo.in. 
I am using custom settings in the below example : i don't know how to achieve this. i wrote below trigger but its not working please help me.
I stored some values in custom settings. Post an error  if any user try to insert a value already existed in custom settings.
  1. trigger comparingExistedNumbers on Order_Product_Item__c (before insert) 
  2. {
  3.     set<id> setIds = new set<id>();
  4.     for(Order_Product_Item__c orders : trigger.new)
  5.     {
  6.         if(orders.Enter_Number_Value__c != null)
  7.         {
  8.             setIds.add(orders.Enter_Number_Value__c);
  9.         }
  10.         list<Order_Product_Item__c> listofOrders = [select id, Enter_Number_Value__c from Order_Product_Item__c where id in:setIds];
  11.         list<string> values = new list<string>();
  12.         list<preDefinedValueList__c> cusList = preDefinedValueList__c.getAll().values(); // getting list of values in Custom settings
  13.         for(Order_Product_Item__c newOrders:listofOrders)
  14.         {
  15.         for(preDefinedValueList__c custom : cusList)
  16.             {
  17.             //system.debug('' +custom.code__c);
  18.            // system.debug('' +custom.Number__c);
  19.             values.add(custom.Number__c); // data set strings storing in values variable
  20.             }
  21.         for(integer i=0; i<values.size();i++)
  22.             {        //comparing values
  23.                 if(newOrders.Enter_Number_Value__c ==values[i]){
  24.                     newOrders.Enter_Number_Value__c.addError('Do not enter existing values');
  25.                 }
  26.             }
  27.         }
  28.     }
  29. }
I was stored a list of numbers in customSettings__c
i have a "Enter_Number__c " field on Object__c.
Then if a user enter any value already existed in the customSettings__c, it will throw an error. 
How can we do that.
1.Using Trigger
2.Using Validations.   please help me out.
Hi i developed below page for displaying childs of account in the page. But when i click on child record tab it refreshing all the page. But i don't want that to full page refresh . Help out please

Page: <apex:page controller="ApexController" tabStyle="account">
    <apex:pageBlock mode="Edit" >
        <apex:pageBlockSection title="Master Record Details" columns="1" >
            <apex:outputField value="{!MasterRecord.Name}" />
            <apex:outputField value="{!MasterRecord.Country__c}"  />
            <apex:outputField value="{!MasterRecord.Phone}"  />
        </apex:pageBlockSection>
    </apex:pageBlock>
    <apex:pageBlock >
        <apex:pageBlockSection title="Displaying Child Records" columns="1">       
                <apex:tabPanel id="tbpanel1"> 
                    <apex:tab label="Contact">                    
                    <apex:outputPanel id="conPanel">
                    <apex:pageBlockTable value="{!ChildRecords}" var="con">
                            <apex:column value="{!con.FirstName}" />
                            <apex:column value="{!con.LastName}" />
                            <apex:column value="{!con.Phone}" />
                     </apex:pageBlockTable>
                     </apex:outputPanel>
                     </apex:tab>
                     <apex:tab label="Opportunity" id="oppTab">                 
                        <apex:outputPanel id="oppPanel">
                        <apex:pageBlockTable value="{!oppChildRecords}" var="opp" id="opps" >
                            <apex:column value="{!opp.Name}" />
                            <apex:column value="{!opp.Amount}" />
                            <apex:column value="{!opp.OrderNumber__c}" />
                        </apex:pageBlockTable>
                        </apex:outputPanel>
                     </apex:tab>
                 </apex:tabPanel>
            
            </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>
Controller:

public with sharing class ApexController {

    public String MasterRecordId        {get; set;}
    public List<contact> ChildRecords  {get; set;}
    public account MasterRecord       {get; set;}
    public List<opportunity> oppChildRecords {get; set;}
    
    public ApexController()
    {
        MasterRecordId = ApexPages.currentPage().getParameters().get('id');
        
        if(!String.isBlank(MasterRecordId)){
           
            MasterRecord =[SELECT Name,Country__c,Phone FROM account WHERE Id = :MasterRecordId ];
            
           ChildRecords =[SELECT FirstName,LastName,Phone FROM contact WHERE accountId = :MasterRecordId];
            oppChildRecords =[SELECT Name,Amount,OrderNumber__c FROM opportunity WHERE accountId = :MasterRecordId];
        }
    }
}
Suppose I want to update or insert records of 10 users From SAP to Salesforce using dataLoader. SAP user id and Salesforce user id are different
example: SAP User1 id== 11111 and salesforce User1 id == 22222 .How can we map those records.
 
Account====AccountTeam
Opportunity === OpportunityTeam
When I deleted Account team member from AccountTeam then automatically a member from OpportunityTeam also be deleted. How can we achieve this.
 
  1. Account ==== Contact   on contact Status__C field is there (Total 10 records)
If one record status is changed to Approved then ‘Remaining 9 records status__c would be changed to Declined ’ . But first Record Status__c  would be Same(Approved).
How can we achieve this through?
1.trigger
2. Process Builder
  1. Account ==== Contact   on contact Status__C field is there (Total 10 records)
1.When we need OutBound Messages and What we will include in outBound Messages
2. what type of data we can send.
3.And what are the limts on outBound messages 
4.Is there any other option to send outbound messages except Workflow
 
I used following component and controller with apex class: But i am knew to lightning, Please help me how to display related contactlist with accountid in new window...
DisplayAccountsWithContacts.cmp:
  1. <aura:component controller="accountsWithContactsClass" implements="flexipage:availableForAllPageTypes" access="global">
  2.    <aura:handler name="init" value="{!this}" action="{!c.myAction}"/>
  3.    <aura:attribute name="accounts" type="account[]"/>
  4.    <table>
  5.         <tr>
  6.             <td> Name </td>
  7.             <td> Industry </td>
  8.             <td> Phone</td>
  9.             <td> CreatedDate</td>
  10.             <td> ContactList Button</td>
  11.          </tr> <b/>
  12.          <aura:iteration items="{!v.accounts}" var="accs1" >
  13.                <tr>
  14.                 <td> {!accs1.Name} </td>
  15.                 <td> {!accs1.Industry} </td>
  16.                 <td> {!accs1.Phone} </td>
  17.                 <td> {!accs1.CreatedDate}</td>
  18.                 <td> <lightning:button variant="neutral" label="ContactList" onclick="{! c.handleClick }" /> 
  19.                    </td>
  20.                </tr><b/>
  21.          </aura:iteration>
  22.     </table>
  23.     <aura:attribute name="isOpen" type="boolean" default="false"/>
  24.          <div class="slds-m-around--xx-large">
  25.                 <aura:if isTrue="{!v.isOpen}">
  26.                  <div role="dialog" tabindex="-1" aria-labelledby="header99" class="slds-modal slds-fade-in-open ">
  27.                     <div class="slds-modal__container">
  28.                   <!-- ###### MODAL BOX HEADER Part Start From Here ######-->
  29.                       <div class="slds-modal__header">
  30.                     <button class="slds-button slds-modal__close slds-button--icon-inverse" title="Close" onclick="{!c.closeModel}">
  31.                     <span class="slds-assistive-text">Close</span>
  32.                     </button>
  33.                     <h2 id="header99" class="slds-text-heading--medium">ContactList</h2>
  34.                   <!--###### MODAL BOX FOOTER Part Start From Here ######-->
  35.                       <div class="slds-modal__footer">
  36.                         <button class="slds-button slds-button--neutral" onclick="{!c.closeModel}" >Cancel</button>
  37.                         <button class="slds-button slds-button--brand" onclick="{!c.likenClose}">Like and Close</button>
  38.                       </div>
  39.                       </div>
  40.                             
  41.                     </div>
  42.                    </div>
  43.                 </aura:if>
  44.          </div>
  45. </aura:component>
DisplayAccountsWithContactsController.js:
  1. ({    
  2.     myAction : function(component, event, helper) {
  3.         var action =component.get("c.getAllAccounts");
  4.         console.log('The action value is: '+action);
  5.          action.setCallback(this, function(a){              
  6.             component.set("v.accounts", a.getReturnValue());
  7.            //  console.log('The accs are :'+JSON.stringify(a.getReturnValue()));
  8.             console.log('The accs are :'+JSON.stringify(a.getReturnValue()));          
  9.         });
  10.         $A.enqueueAction(action);
  11.     },
  12.     handleClick : function(component, event, helper) { 
  13.         component.set("v.isOpen", true);   // for Hide/Close Model,set the "isOpen" attribute to "Fasle" 
  14.     }  , 
  15.       closeModel: function(component, event, helper) {
  16.          component.set("v.isOpen", false); // for Hide/Close Model,set the "isOpen" attribute to "Fasle"        
  17.    },
  18.    likenClose: function(component, event, helper) {
  19.         alert('thanks for like Us :)');// Display alert message on the click on the "Like and Close" button from Model Footer 
  20.                                        // and set set the "isOpen" attribute to "False for close the model Box.
  21.         component.set("v.isOpen", false);
  22.    },
  23. })
accountswithContactsClass.apxc:
public class accountsWithContactsClass {
    @auraEnabled
public static list<account> getAllAccounts()
    {
     list<account> accs =[select id,name,phone,industry,CreatedDate from account limit 10];
     return accs;
    }
}
===================================================================================================
User-added image











 
App:
  1. <aura:application  access="global" extends="ltng:outApp">
  2.     <aura:dependency resource="c:flipCard" />
  3.     
  4. </aura:application>
component:
  1. <aura:component >
  2.     <aura:attribute type="string" name="bgColor" />
  3.     <aura:attribute type="string" name="fontColor" default="#000"/>
  4.     <aura:attribute type="string" name="borderColor" default="#000"/>
  5.     <aura:attribute type="string" name="frontText" />
  6.     <aura:attribute type="string" name="backText" /> 
  7.     <aura:attribute type="boolean" name="isVerticalFlip" default="false" description="By default its Horizontal flip" />
  8. <div class="{! 'slds flip-container ' + (v.isVerticalFlip == false ? 'horizontal' : 'vertical') }" style="{! 'background-color:'+ v.bgColor+'; color: '+ v.fontColor+';border : 1px solid '+ v.borderColor}">
  9. <div class="flipper">
  10. <div class="front">
  11.                 {!v.frontText}
  12.             </div>
  13. <div class="back">
  14.                 {!v.backText}
  15.             </div>
  16.         </div>
  17.     </div>
  18. </aura:component>
Css:
  1. .slds.THIS{
  2.     padding : 10px;
  3.     margin : 10px; 
  4.     display: inline-block;
  5.     border-radius: 15px;
  6.     text-align: center;
  7.     font-size : 2em;
  8.  
  9. .THIS .flip-container {
  10.     perspective: 1000px;
  11. /* hide back while swapping*/
  12. .THIS .front, .THIS .back {
  13.     backface-visibility: hidden; 
  14.     position: absolute;
  15.     top: 0;
  16.     left: 0;
  17. }
  18.  
  19. .THIS.flip-container, .THIS .front, .THIS .back {
  20.     width: 100%;
  21.     height: 100%;
  22. }
  23. .THIS .front {
  24.     z-index: 2;  
  25. }
  26.  
  27. /* Flip Speed */
  28. .THIS .flipper {
  29.     transition: 0.6s;
  30.     transform-style: preserve-3d; 
  31.     position: relative; 
  32.  
  33. .THIS.flip-container.horizontal:hover .flipper, .THIS.flip-container.horizontal.hover .flipper {
  34.         transform: rotateY(180deg);
  35. }
  36.  
  37. .THIS.horizontal .front { 
  38.     transform: rotateY(0deg);
  39. }
  40.  
  41. /* back, initially hidden pane */
  42. .THIS.horizontal .back {
  43.     transform: rotateY(180deg);
  44. }
  45.  
  46. .THIS.flip-container.vertical:hover .flipper, .THIS.flip-container.vertical.hover .flipper {
  47.         transform: rotateX(180deg);
  48. }
  49.  
  50. .THIS.vertical .front { 
  51.     transform: rotateX(0deg);
  52. }
  53.  
  54. /* back, initially hidden pane */
  55. .THIS.vertical .back {
  56.     transform: rotateX(180deg);
  57. }
VF page:
  1. <apex:page >
  2.     <apex:includeLightning />
  3.     <div style="width:50%;height:150px;" id="flipCardId" />
  4.     <script>
  5.     $Lightning.use("c:lightningOutAppContainer",
  6.                    function(){
  7.                    $Lightning.createComponent("c:flipCard",
  8.                           {
  9.                               borderColor: "green",
  10.                               bgColor:"white",
  11.                               fontColor:"red",
  12.                               frontText:"What is a cool about Lightning Component Development",
  13.                               backText:"You do not need to enable Lightning experience, it will work on Classic instance as well"
  14.                          },
  15.                              "flipCardId",
  16.                                function(cmp){
  17.                                console.log('Component created, do something cool here')
  18.                                });
  19.                    });
  20.     </script>
  21. </apex:page>
please help me, why background color of a flipcard is not working.
AccountListComponent.cmp:
  1. <aura:component controller="AccountListController">
  2.     <aura:attribute name="Accounts" type="account[]"/>
  3.     <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
  4.     <aura:iteration items="{!v.Accounts}" var="acc">
  5.         <ui:outputText value="{!acc.name}"/>
  6.     </aura:iteration>
  7. </aura:component>
AccountListComponentController.js:
  1. ({
  2.     doInit : function(component, event, helper) {
  3.         var action = component.get("c.getAccounts");
  4.         
  5.         action.setCallback(this, function(response){
  6.             var state = response.getState();
  7.             $A.log(response);
  8.             if(state == "SUCCESS"){
  9.                 component.set("v.Accounts", response.getReturnValue());
  10.             }
  11.         });
  12.         $A.enqueueAction(action);
  13.     }
  14. })
AccountListController.apxc:
  1. public class AccountListController {
  2.     @AuraEnabled
  3.     public static List<account> getAccounts(){
  4.        list<account> accs =[select id,name from account];
  5.      return accs;
  6.     }
  7. }
harnessApp.app:
  1. <aura:application >
  2.     <div style="height: 400px;overflow: scroll; padding-top: 10px;">
  3.     <c:AccountListComponent />
  4.     </div>
  5. </aura:application>
Please give me a solution.
Below is the code how can we write test class for this page with controller. Please help me
<apex:page controller="listViewsForContactRecords">
<apex:form >
            <apex:pageBlock >
           
            <apex:pageBlockTable value="{!accountsToDisplay}" var="acc" columns="2" id="pgtparent">
            <apex:column headerValue="AccountName" >
            <apex:commandLink value="{!acc.name}" action="{!MethodToCall}" rerender="pgbContacts" status="status">
            <apex:param value="{!acc.Id}" name="idForConts" assignTo="{!recid}"/>
            </apex:commandLink>
            </apex:column>
            <apex:column value="{!acc.Phone}"/>
            </apex:pageblockTable>
            </apex:pageBlock> 
    <apex:pageBlock title="Account Related Contacts"> 
       
    <apex:outputPanel id="pgbContacts">
    <apex:actionStatus startText="Please Wait Loading..." stopText="" id="status"></apex:actionStatus>
    <apex:pageblockTable value="{!conList }" var="cons">
    <apex:column headerValue="FirstName">
    <apex:inputText value="{!cons.FirstName}"/>
    </apex:column>
    <apex:column headerValue="LastName">
    <apex:inputText value="{!cons.LastName}"/>
    </apex:column>
    <apex:column >
    <apex:commandButton value="EditContact"/>
    </apex:column>
    </apex:pageblockTable>
    </apex:outputPanel> 
    </apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class listViewsForContactRecords {

    public list<contact> conList{get;set;}
    public string recid{get;set;}

    set<id> accIds = new set<id>();
    public list<account> accountsToDisplay{get;set;}
    public account getAcounts() {
        return null;
    }

public listViewsForContactRecords(){
accountsToDisplay = [select id, name, phone from account limit 10];

}
 public void MethodToCall() {
        conList = [select id, FirstName, LastName from contact where accountid=:recid];

    }
}
if birt date of contact is 30th august , how can we send wishes alert to the contact  at 29th august 11:55pm.

​How can we achieve this please help me.
Hi i used below code but its not working fine
1. Only one account record is displaying in first page
2.Popup window is not closing after record update or cancel.

Below is my code:
Page1:
<apex:page standardController="Account" recordSetVar="accs">
<script>
  function OpenVfpage(pid){
      var newwindow = window.open('/apex/Accsmallpopup?id='+pid, 'name=_blank','height=500,width=500,left=250,top=100'); 
  newwindow.focus();
 }
</script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!accs}" var="a" >
                <apex:column value="{!a.Id}"/>
                <apex:column value="{!a.name}"/>
                <apex:column value="{!a.Phone}"/>
                <apex:column value="{!a.Industry}"/>
                <apex:column id="two">
                    <apex:commandButton value="Click" onclick="OpenVfpage('{!a.id}')" reRender="two"/>
               </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Page2:
<apex:page controller="Accpopup2" showHeader="false" sidebar="false" id="the">
   <apex:form id="page">
    <apex:pageblock id="close">
    <apex:pageBlockSection >
        <apex:inputfield value="{!a.Name}"/>
         <apex:inputfield value="{!a.Phone}"/>
     </apex:pageBlockSection>
        <apex:pageblockbuttons >
        <apex:commandButton value="save" action="{!save}"/>
        <apex:commandButton value="cancel" action="{!cancel}"/>
            </apex:pageblockbuttons>
            <apex:inputHidden id="pass" value="{!status}"/>
             </apex:pageblock>
        
            <script language="JavaScript" type="text/javascript">
            if(document.getElementById('the:page:close:pass').getAttribute('value') == 'true')
                {
                    window.top.close();
                }
            </script>   
             </apex:form>
</apex:page>

Controller: 
public class Accpopup2 
{
    public Account a {get;set;}
    public string status {get;set;}
    public Accpopup2()
    {
      a = new account();  
    }
    public pagereference save()
    {
    ID caseID = apexpages.currentPage().getParameters().get('id');
    if(caseid!=null)
    {
        account acc = [select Name,Phone from account where ID =: caseID];
        acc.Name = a.Name;
        acc.Phone = a.Phone;
        update acc;
    }
       
        return null;
    }
    
    public pagereference cancel()
    {
        status = 'true';
          return null;    
    }
}

global class batchForinsertingAccounts implements Database.Batchable<sObject>, Database.Stateful{
global integer count;
global string query;
global Database.QueryLocator start(Database.BatchableContext BC){
      count=0;
      return null;
}
global void execute(Database.BatchableContext BC, List<account> scope){
count=0;
list<Account> Llist = new list<Account>();
for(account acc:scope){
for(integer i=0;i<=20000 ;i++){
Account a = new account();
a.name = 'TulasiRam'+i;
Llist.add(acc);
count++;
}
}
database.insert(Llist);

}
global void finish(Database.BatchableContext BC){

system.debug(''+count);
}
}
I am using custom settings in the below example : i don't know how to achieve this. i wrote below trigger but its not working please help me.
I stored some values in custom settings. Post an error  if any user try to insert a value already existed in custom settings.
  1. trigger comparingExistedNumbers on Order_Product_Item__c (before insert) 
  2. {
  3.     set<id> setIds = new set<id>();
  4.     for(Order_Product_Item__c orders : trigger.new)
  5.     {
  6.         if(orders.Enter_Number_Value__c != null)
  7.         {
  8.             setIds.add(orders.Enter_Number_Value__c);
  9.         }
  10.         list<Order_Product_Item__c> listofOrders = [select id, Enter_Number_Value__c from Order_Product_Item__c where id in:setIds];
  11.         list<string> values = new list<string>();
  12.         list<preDefinedValueList__c> cusList = preDefinedValueList__c.getAll().values(); // getting list of values in Custom settings
  13.         for(Order_Product_Item__c newOrders:listofOrders)
  14.         {
  15.         for(preDefinedValueList__c custom : cusList)
  16.             {
  17.             //system.debug('' +custom.code__c);
  18.            // system.debug('' +custom.Number__c);
  19.             values.add(custom.Number__c); // data set strings storing in values variable
  20.             }
  21.         for(integer i=0; i<values.size();i++)
  22.             {        //comparing values
  23.                 if(newOrders.Enter_Number_Value__c ==values[i]){
  24.                     newOrders.Enter_Number_Value__c.addError('Do not enter existing values');
  25.                 }
  26.             }
  27.         }
  28.     }
  29. }
Which profile should be assigned for a User(Developer) in Real time. and what is the difference between Enhanced and Non-Enhanced user Interfaces Please help me .
Case 1: I used Standard Controller with Extension controller . Then what type of Apex sharing rules will be enforced on extensions.
case 2: I used custom controller with Extension controller . Then what type of Apex sharing rules will be enforced on extensions.