• Rakesh Imsani
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 10
    Replies
Hi Friends

I am facing a issue with how can to get  one components attribute value to another component

 
 I have Two components 1) FormComponent and 2) PrintComponent
 
 I need FormComponent's OppId attribute in PrintForm's Java script controller.
 
 How can i get the attribute?
 
 Below is the code skeleton
 
 FormComponent.cmp
 ----------------
 
 <aura:component controller="FormController">
 <aura:attribute name="oppId" type="String" default=""/> 
    <lightning:layout>
 
 <lightning:layoutItem padding="horizontal-small" largeDeviceSize="3" mediumDeviceSize="3" smallDeviceSize="12" size="12">
                    <lightning:button variant="brand" label="Print Forms" title="Print Loan Agreement" onclick="{!c.printForms}" />
                     
                   </lightning:layoutItem>
                   
                   </lightning:layout>
  
    
</aura:component>



FormComponentcontroller.js
------------------------------


({
    doInit: function(component, event, helper){
},

 printForms : function(component, event, helper){
 
 // need to send oppId to another component PrintForm
 
 }
})



PrintForm.cmp
-------------

<aura:component implements="force:appHostable,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
                access="global"
                controller="PrintController">
    
     <aura:attribute name="oppId" type="String" default=""/>
     
     <!--  logic to implement the datatable to view the data -->
     
</aura:component>


PrintFormController.js
-----------------------


{
    doInit: function(component, event, helper){
// how can i get the oppId value from Form component
},

 
From trigger i am calling this following class/method, how can write Test class.


global class FutureClass{

 @Future (callout=true)
    public static void SendCaseData(String sCaseNo,String sCaseEmail, String sCaseContact)
    {
       
//WSDL2Apex class     
 SF2ERPCase.SFSendSoap sfsend = new F2ERPCase.SFSendSoap();
          
        String parmXML;
        
        parmXML = '<Root>';
        parmXML += '<CaseNo>' + sCaseNo + '</CaseNo>';
        parmXML += '<CaseEmail>' + sCaseEmail + '</CaseEmail>';
        parmXML += '<CaseContact>' + sCaseContact  + '</CaseContact>';
        parmXML += '</Root>';
        
        sfsend.RecvMsg(parmXML);
       }
}
Public class CustomCaseAlertsController
{

  public CustomCaseAlertsController(ApexPages.StandardController stdController)
    {
//how to get id here
//how to populate account look up in case obj... please help me
        String caseId = stdController.getId();
        caseObj = [Select id,AccountId,ContactId,CaseNumber from Case where id=:caseId];
        
        
    ......................................
        ................................

     }    

    public void hideAlerts()
    {
        insert ListObj;
    }

}
Public class CustomCaseAlertsController
{
    public Case caseObj {get; set;}
    public boolean hasAlerts
    {
        get{ return (Alerts.size()==0? false: true); }
        set;
    }
    
    public integer popupWindowHeight
    {
        get{ return (230+Alerts.size()*40); }
        set;
    }
    private Set<ID> hattrixParentIds=new Set<ID>();
    private Set<ID> queryAlertIds=new set<ID>();
   
    public List<soalert__Hidden_Alert__c> Alerts {get; set;}
    private List<Hattrix_Account__c> listOfHattrixParent=new List<Hattrix_Account__c>();
    public List<soalert__Hidden_Alert__c> userSelectedAlerts=new List<soalert__Hidden_Alert__c>();
    
    public CustomCaseAlertsController(ApexPages.StandardController stdController)
    {
        String caseId = stdController.getId();
        
         Alerts = new List<soalert__Hidden_Alert__c>();
         Map<Id, soalert__Hidden_Alert__c> mapAlertIdToWrapper = new Map<Id, soalert__Hidden_Alert__c>();
        
        caseObj = [Select id,AccountId,ContactId,Site__c,Site__r.Name,CaseNumber from Case where id=:caseId];
                                     
                                   
        for(Hattrix_Account__c  idObj:[select id,Hatrix_Parent_Account__c from Hattrix_Account__c where Hatrix_Parent_Account__c =:caseObj.site__c or Hatrix_Parent_Account__c=:caseObj.accountID])
            {
                hattrixParentIds.add(idObj.id);
            }

                            
        for(soalert__Alert__c alertObj: [SELECT Id,Name,soalert__Account__c,soalert__Account__r.Name,soalert__Contact__c,soalert__Contact__r.Name,soalert__Alert_Begin_Date__c,soalert__Alert_End_Date__c,soalert__Alert_Message__c,soalert__Alert_Status__c,soalert__Case__c,soalert__User__c FROM soalert__Alert__c 
                                        Where ((soalert__Case__c=:caseObj.Id  or  soalert__Account__c=:caseObj.AccountId or soalert__Account__c=:caseobj.Site__c or  soalert__Account__c in:hattrixParentIds or soalert__Contact__c=:caseObj.ContactId) and  (soalert__Alert_Begin_Date__c <= today and soalert__Alert_End_Date__c >= today))] )
                        
        {
            soalert__Hidden_Alert__c alertWrapper = new soalert__Hidden_Alert__c();
                        
            alertWrapper.soalert__Alert__c=alertObj.Id;
            alertWrapper.soalert__Hidden__c = false;
            alertWrapper.soalert__Alert_Message__c = alertObj.soalert__Alert_Message__c;
            alertWrapper.soalert__User__c = UserInfo.getUserId(); 
                                                                                       
            if(alertObj.soalert__Account__c != null)
            {
               
                alertWrapper.soalert__Object_ID__c=alertObj.soalert__Account__c;
                alertWrapper.soalert__Object_Type__c=alertObj.soalert__Account__c.getSObjectType().getDescribe().getLabel();
                alertWrapper.soalert__Record_Name__c = alertObj.soalert__Account__r.Name;
                System.debug('alertObj.soalert__Account__c.getSObjectType().getDescribe().getLabel();'+alertObj.soalert__Account__c.getSObjectType().getDescribe().getLabel());
            }
            else if(alertObj.soalert__Contact__c !=null)
            {
                                 
                // alertWrapper.soalert__Object_Type__c=alertObj.soalert__Contact__c.getSObjectType().getDescribe().getLabel();
                alertWrapper.soalert__Object_ID__c=alertObj.soalert__Contact__c;
                alertWrapper.soalert__Object_Type__c=alertObj.soalert__Contact__c.getSObjectType().getDescribe().getLabel();
                alertWrapper.soalert__Record_Name__c = alertObj.soalert__Contact__r.Name;
                            
                                  
            } 
            else if(alertObj.soalert__Case__c !=null)
            {
                System.debug('case');
                //alertWrapper.soalert__Object_Type__c=alertObj.soalert__Case__c.getSObjectType().getDescribe().getLabel();
                alertWrapper.soalert__Object_ID__c=alertObj.soalert__Case__c;
                alertWrapper.soalert__Object_Type__c=alertObj.soalert__Case__c.getSObjectType().getDescribe().getLabel();
                alertWrapper.soalert__Record_Name__c = caseObj.CaseNumber;// need to clarify
                                          
            }
            
            mapAlertIdToWrapper.put(alertObj.Id, alertWrapper);
            
            //Alerts.add(alertWrapper);
        }
                                      
      for (soalert__Hidden_Alert__c hiddenObj: [Select id,soalert__Alert__c,soalert__User__c  from soalert__Hidden_Alert__c 
                                                    where (soalert__User__c=:UserInfo.getUserID() and soalert__Hidden__c=true 
                                                    and soalert__Alert__c in : mapAlertIdToWrapper.KeySet())])
        {
             mapAlertIdToWrapper.remove(hiddenObj.soalert__Alert__c);
        }
        
        Alerts = mapAlertIdToWrapper.values();
    }      
           
    public void hideAlerts()
    {  
        //Method for hiding the selected alerts 
        for(soalert__Hidden_Alert__c c: Alerts)
        {
            if(c.soalert__Hidden__c==true )
            {
                userSelectedAlerts.add(c);
            }
        }
        
        insert userSelectedAlerts;
    }
}
Hi Friends

I am facing a issue with how can to get  one components attribute value to another component

 
 I have Two components 1) FormComponent and 2) PrintComponent
 
 I need FormComponent's OppId attribute in PrintForm's Java script controller.
 
 How can i get the attribute?
 
 Below is the code skeleton
 
 FormComponent.cmp
 ----------------
 
 <aura:component controller="FormController">
 <aura:attribute name="oppId" type="String" default=""/> 
    <lightning:layout>
 
 <lightning:layoutItem padding="horizontal-small" largeDeviceSize="3" mediumDeviceSize="3" smallDeviceSize="12" size="12">
                    <lightning:button variant="brand" label="Print Forms" title="Print Loan Agreement" onclick="{!c.printForms}" />
                     
                   </lightning:layoutItem>
                   
                   </lightning:layout>
  
    
</aura:component>



FormComponentcontroller.js
------------------------------


({
    doInit: function(component, event, helper){
},

 printForms : function(component, event, helper){
 
 // need to send oppId to another component PrintForm
 
 }
})



PrintForm.cmp
-------------

<aura:component implements="force:appHostable,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
                access="global"
                controller="PrintController">
    
     <aura:attribute name="oppId" type="String" default=""/>
     
     <!--  logic to implement the datatable to view the data -->
     
</aura:component>


PrintFormController.js
-----------------------


{
    doInit: function(component, event, helper){
// how can i get the oppId value from Form component
},

 
From trigger i am calling this following class/method, how can write Test class.


global class FutureClass{

 @Future (callout=true)
    public static void SendCaseData(String sCaseNo,String sCaseEmail, String sCaseContact)
    {
       
//WSDL2Apex class     
 SF2ERPCase.SFSendSoap sfsend = new F2ERPCase.SFSendSoap();
          
        String parmXML;
        
        parmXML = '<Root>';
        parmXML += '<CaseNo>' + sCaseNo + '</CaseNo>';
        parmXML += '<CaseEmail>' + sCaseEmail + '</CaseEmail>';
        parmXML += '<CaseContact>' + sCaseContact  + '</CaseContact>';
        parmXML += '</Root>';
        
        sfsend.RecvMsg(parmXML);
       }
}
Public class CustomCaseAlertsController
{

  public CustomCaseAlertsController(ApexPages.StandardController stdController)
    {
//how to get id here
//how to populate account look up in case obj... please help me
        String caseId = stdController.getId();
        caseObj = [Select id,AccountId,ContactId,CaseNumber from Case where id=:caseId];
        
        
    ......................................
        ................................

     }    

    public void hideAlerts()
    {
        insert ListObj;
    }

}