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

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 60
    Questions
  • 66
    Replies
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.