• Aishwarya Bhat 1
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 2
    Replies
Hello All,

I have used lightining tabset in which it contains 3 tabs :Leads , Contacts ,Custom Email .I want to display the list of records of leads and contacts But my issue is that initially for default tab I am not able to see the list of records. I am attching the code of the same.
########### COMPONENT########################

<aura:component controller="ContactPagination" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
    <ltng:require styles="/resource/slds/assets/styles/salesforce-lightning-design-system.css" />
     <aura:attribute name="listOFrecipients" type="SurveyBuilder__SurveyRecipient__c[]"/>
      <aura:attribute name="surveyId" type="String" />
    <aura:attribute name="name" type="string" />
    <aura:attribute type="Contact[]" name="paginationList" />
    <aura:attribute type="Lead[]" name="paginationListLeads" />
    <aura:attribute type="Integer" name="pageNumber" default="1" />
    <aura:attribute type="Integer" name="maxPage" default="1" />
    <aura:attribute type="String" name="CustomEmails"/>
    
     <aura:attribute name="selTabId" type="string"  />
    
    <aura:handler name="change" value="{!v.pageNumber}" action="{!c.renderPageLeads}" />
    
    <aura:handler name="change" value="{!v.pageNumber}" action="{!c.renderPage}" />
    
    <aura:attribute name="myLeadData" type="Object"/>
    
    <aura:attribute name="mydata" type="Object"/>
    
    <aura:attribute name="myLeadColumns" type="List"/>
    <aura:attribute name="mycolumns" type="List"/>
    
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    
    <c:surveyHeader/>
    <div class="body">
        <div class="bodyContainer">
            <div class="black"></div>
            <div class="slds-size_8-of-8 dashbrdblock">
                
                <div class="sectionTitle">
                    Add Recipients to Survey
                </div>
                <div class="Outer-Box">
                    <div id="warn"  >
                        <ui:message title="Warning" severity="warning" >
                            Please select the recipient!
                        </ui:message>
                    </div>
                    <lightning:tabset selectedTabId="{!v.selTabId}" >
                        
                        <lightning:tab label="Lead" onactive="{!c.renderPageLeads}" id="1">
                            <div class="slds-list_horizontal"  style="padding:1%;">
                                <div class="slds-list_horizontal"  >
                                    <ui:inputText label="Name : " value="{!v.name}"/>
                                </div>
                                <div class="slds-list_horizontal"  >
                                    <ui:inputText label="   Email Address : "  value="{!v.name}" />
                                </div>
                                <button type="button" class="slds-button-neutral">Search</button> 
                                
                            </div>
                          
                            <lightning:datatable data="{! v.myLeadData }"
                                                 columns="{! v.myLeadColumns }"
                                                 keyField="id"
                                                 onrowselection="{! c.getSelectedNameOfLeads }"/>
                            <div class="pagination-box" style="float:right;">
                                <c:Pagination currentPageNumber="{!v.pageNumber}" maxPageNumber="{!v.maxPage}" />
                            </div>    
                            
                        </lightning:tab>
                        <lightning:tab label="Contact" onactive="{!c.renderPage}" id="2">
                            
                            <lightning:datatable data="{! v.mydata }"
                                                 columns="{! v.mycolumns }"
                                                 keyField="id"
                                                 onrowselection="{! c.getSelectedNameOfContacts }"/>
                            <div class="pagination-box" style="float:right;">
                                <c:Pagination currentPageNumber="{!v.pageNumber}" maxPageNumber="{!v.maxPage}" />
                            </div>
                        </lightning:tab>    
                        <lightning:tab label="Custom Email" id="3">
                          
                              <lightning:input class="input" name="Email" label="Enter Email" aura:id="listOfEmails" placeholder="Type emails separated by ','"/>
                        <lightning:button variant="brand" label="Save" title="Next" onclick="{! c.saveEmails }"/>

                        </lightning:tab>
                    </lightning:tabset>
                </div>
                 <div class="feild">
                <button type="button" onclick="{!c.sendSurvey}"  class="slds-button-neutral green-btn addnew-btn">Next</button> 
                <!--  <lightning:button onclick="{!c.createSurveyQuestion}" id="{!newSurvey.Id}" class="slds-button-neutral green-btn addnew-btn" label="Next" />-->
                <!--<lightning:button onclick="{!c.navigateToMQuestions}" class="green-btn default-btn" label="Next" />  -->
            </div>
            </div>
             
        </div>
    </div>
</aura:component>


####################### CONTROLLER ##############################

({init: function (cmp, event, helper) {
  
  
    cmp.set('v.myLeadColumns', [
        { label: 'Name', fieldName: 'Name', type: 'text'},
        { label: 'Phone', fieldName: 'Phone', type: 'phone'},
        { label: 'Email', fieldName: 'Email', type: 'email'}
    ]);

    helper.getData(cmp,event,helper);
    this.renderPageLeads(cmp,event,helper);
    
    cmp.set('v.mycolumns', [
        { label: 'Name', fieldName: 'Name', type: 'text'},
        { label: 'Phone', fieldName: 'Phone', type: 'phone'},
        { label: 'Email', fieldName: 'Email', type: 'email'}
    ]);
   
    helper.getData1(cmp,event,helper);

},
  renderPageLeads: function(cmp, event, helper) {
    
      //document.getElementById('warn').style.display = 'none';
 
      var records = cmp.get("v.paginationListLeads"),
         
          pageNumber = cmp.get("v.pageNumber"),
          pageRecords = records.slice((pageNumber-1)*10, pageNumber*10);
      cmp.set("v.myLeadData", pageRecords);
      alert("===>renderPageLeads" +records);
  },
  renderPage: function(cmp, event, helper) {
       document.getElementById('warn').style.display = 'none';
      var records = cmp.get("v.paginationList"),
          
          pageNumber = cmp.get("v.pageNumber"),
          pageRecords = records.slice((pageNumber-1)*10, pageNumber*10);
      cmp.set("v.mydata", pageRecords);
  },
  getSelectedNameOfLeads : function (cmp, event) {
        document.getElementById('warn').style.display = 'none';
      var selectedRows = event.getParam('selectedRows');
      var idx =cmp.get("v.surveyId");
      var action = cmp.get("c.addRecipentsLead");
      action.setParams({ "resObj" : selectedRows,
                        "surveyId":idx});
      action.setCallback(this, function(a) {
          
          var state = a.getState();
          if (state === "SUCCESS") {
              alert("Success Lead");
          }
          else
          {
              alert("Error Lead");
          }

      });
      $A.enqueueAction(action);
      // Display that fieldName of the selected rows
      
  },
  getSelectedNameOfContacts : function (cmp, event) {
            document.getElementById('warn').style.display = 'none';
      var selectedRows = event.getParam('selectedRows');
      var idx =cmp.get("v.surveyId");
      var action = cmp.get("c.addRecipentsContact");
      action.setParams({ "resObj" : selectedRows,
                        "surveyId":idx});
      action.setCallback(this, function(a) {
          
          var state = a.getState();
          if (state === "SUCCESS") {
              alert("Success Contact");
          }
          else
          {
              alert("Error Contact");
          }
          
          
          
      });
      $A.enqueueAction(action);
      // Display that fieldName of the selected rows
      
  },
  getSelectedName: function (cmp, event) {
       document.getElementById('warn').style.display = 'none';
      var selectedRows = event.getParam('selectedRows');
      var idx =cmp.get("v.surveyId");
      var action = cmp.get("c.addRecipentsCustom");
      action.setParams({ "resObj" : selectedRows,
                        "surveyId":idx});
      action.setCallback(this, function(a) {
          
          var state = a.getState();
          if (state === "SUCCESS") {
              alert("Success Contact");
          }
          else
          {
              alert("Error Contact");
          }
          
          
          
      });
      $A.enqueueAction(action);
      
      // Display that fieldName of the selected rows
      //  for (var i = 0; i < selectedRows.length; i++){
      //  alert(JSON.stringify(selectedRows[i]));
      //}
  },
  saveEmails:function(cmp,event){
      document.getElementById('warn').style.display = 'none';
      var listOfEmail=cmp.find("listOfEmails").get("v.value");
      
      // alert(listOfEmail);
      // var selectedRows = event.getParam('selectedRows');
      var idx =cmp.get("v.surveyId");
      var action = cmp.get("c.addRecipentsCustom");
      action.setParams({ "resObj" : listOfEmail,
                        "surveyId":idx});
      action.setCallback(this, function(a) {
          
          var state = a.getState();
          if (state === "SUCCESS") {
              alert("Success ");
          }
          else
          {
              alert("Error ");
          }
          
          
          
      });
      $A.enqueueAction(action);
      
      
  },
  sendSurvey: function(component, event, helper) {
      var idx1 =component.get("v.surveyId");
      var action = component.get("c.getRecipients");
      action.setParams({ 
          "surveyId":idx1});
      action.setCallback(this, function(a) {
          var response=a.getReturnValue();
          alert('So ja varna hastar aa jayega:::::::::'+JSON.stringify(response));
          var state = a.getState();
          if (state === "SUCCESS") {
              alert("Success ");
              if(response.length>0)
              {
                   document.getElementById('warn').style.display = 'none';
                  var evt = $A.get("e.force:navigateToComponent");
                  // var rec=  component.get("v.surveyId");
                  var idx =component.get("v.surveyId");
                  alert("Inside if" +idx);
                  alert("Survey id in create Survey :"+idx);
                  evt.setParams({ componentDef :"SurveyBuilder:sendSurvey" ,
                                 componentAttributes: {
                                     "surveyId": idx
                                 },});
                  evt.fire();
                
              }
              else
              {
                  
                   document.getElementById('warn').style.display = 'block';
              }
          }
          else
          {
              alert("Error ");
          }
          
          
          
      });
      $A.enqueueAction(action);
      
  }
 })



#############################Helper##############################

({
    getData1 : function(cmp,event,helper) {
        var action = cmp.get('c.getLds');
                
        
        action.setCallback(this, $A.getCallback(function (response) {
            
            var state = response.getState();
           
            var records = response.getReturnValue();
			
            cmp.set("v.paginationListLeads", records);

            cmp.set("v.maxPage", Math.floor((records.length+9)/10));
            
           
            
        }));
        $A.enqueueAction(action);
        
    },
    
    renderLeads: function(cmp,event,helper) {
    
      //document.getElementById('warn').style.display = 'none';
 
      var records = cmp.get("v.paginationListLeads"),
         
          pageNumber = cmp.get("v.pageNumber"),
          pageRecords = records.slice((pageNumber-1)*10, pageNumber*10);
      cmp.set("v.myLeadData", pageRecords);
  },
   
    getData : function(cmp) {
        var action = cmp.get('c.getCntcts');
		
        
              var records = cmp.get("v.paginationListLeads"),
         
          pageNumber = cmp.get("v.pageNumber"),
          pageRecords = records.slice((pageNumber-1)*10, pageNumber*10);
      cmp.set("v.myLeadData", pageRecords);
        
        action.setCallback(this, $A.getCallback(function (response) {
            
            var state = response.getState();
           
            var records = response.getReturnValue();
			
            cmp.set("v.paginationList", records);

            cmp.set("v.maxPage", Math.floor((records.length+9)/10));
            
             
           
        }));
        $A.enqueueAction(action);
    },
     
})

############################ Apex ################################

public with sharing class ContactPagination 
{

      @AuraEnabled
    public static List<Contact> getCntcts() {
        List<Contact> contacts =
                [SELECT Id, Name, Phone, Email FROM Contact limit 100];
        //Add isAccessible() check
        return contacts;
    }
    
          @AuraEnabled
    public static List<Lead> getLds() {
        List<Lead> leads =
                [SELECT Id, Name, Phone, Email FROM Lead limit 100];
        //Add isAccessible() check
        return leads;
    }
    @AuraEnabled
    public static void addRecipentsLead(List<Lead> resObj,String surveyId) {
       // SELECT Id, , SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c, , SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c
       for(Lead l :resObj )
       {
           List<SurveyBuilder__SurveyRecipient__c> existingRecipient =[SELECT Id, SurveyBuilder__SurveyId__c, SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c,  SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c where SurveyBuilder__email__c=:l.Email AND SurveyBuilder__SurveyId__c=:surveyId ];
           if(existingRecipient.size()==0){
           SurveyBuilder__SurveyRecipient__c sr = new SurveyBuilder__SurveyRecipient__c();
           sr.Name='xx';
           sr.SurveyBuilder__SurveyId__c=surveyId;
           sr.SurveyBuilder__email__c=l.Email;
           sr.SurveyBuilder__objectId__c=l.Id;
           sr.SurveyBuilder__typeOfRecipient__c='lead';
           sr.SurveyBuilder__Recipient_Name__c=l.Name;
               insert sr;
                 sr.Name=sr.Id;
                update sr;
           }

       }
    }
    
    @AuraEnabled
    public static void addRecipentsContact(List<Contact> resObj,String surveyId) {
        // SELECT Id, , SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c, , SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c
        for(Contact c :resObj )
        {
            List<SurveyBuilder__SurveyRecipient__c> existingRecipient =[SELECT Id, SurveyBuilder__SurveyId__c, SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c,  SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c where SurveyBuilder__email__c=:c.Email AND SurveyBuilder__SurveyId__c=:surveyId ];
            if(existingRecipient.size()==0){
                SurveyBuilder__SurveyRecipient__c sr = new SurveyBuilder__SurveyRecipient__c();
                sr.Name='xx';
                sr.SurveyBuilder__SurveyId__c=surveyId;
                sr.SurveyBuilder__email__c=c.Email;
                sr.SurveyBuilder__objectId__c=c.Id;
                sr.SurveyBuilder__typeOfRecipient__c='contact';
                sr.SurveyBuilder__Recipient_Name__c=c.Name;
                insert sr;
                sr.Name=sr.Id;
                update sr;
            }
            
        }
    }
    
         
    @AuraEnabled
    public static void addRecipentsCustom(List<String> resObj,String surveyId) {
        // SELECT Id, , SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c, , SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c
        for(String s :resObj )
        {
            List<SurveyBuilder__SurveyRecipient__c> existingRecipient =[SELECT Id, SurveyBuilder__SurveyId__c, SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c,  SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c where SurveyBuilder__email__c=:s AND SurveyBuilder__SurveyId__c=:surveyId ];
            if(existingRecipient.size()==0){
                SurveyBuilder__SurveyRecipient__c sr = new SurveyBuilder__SurveyRecipient__c();
                sr.Name='xx';
                sr.SurveyBuilder__SurveyId__c=surveyId;
                sr.SurveyBuilder__email__c=s;
              
                sr.SurveyBuilder__typeOfRecipient__c='custom';
               sr.SurveyBuilder__Recipient_Name__c='Custom Email';
                insert sr;
                  sr.Name=sr.Id;
                update sr;
            }
            
        }
    }
    @AuraEnabled
    public static   List<SurveyBuilder__SurveyRecipient__c> getRecipients(String surveyId) {
        // SELECT Id, , SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c, , SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c
        List<SurveyBuilder__SurveyRecipient__c> existingRecipient =[SELECT Id, SurveyBuilder__SurveyId__c, SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c,  SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c where  SurveyBuilder__SurveyId__c=:surveyId ];
        
        return  existingRecipient;           
    }
    
}

Thank you in advance.!
Hello All,

I want that on case creation in any of the shopping websites (Flipkart,amazon,snapdeal,pepperfry), it should create a case in salesforce.. 

Thank you in Advance!
Hi All,

I want to display an error message in salesforce when there is unsuccessful sync from salesforce to unleashed. Is there any way from which I can get the the error code generated in unleashed at the time of sync and how can I access the same in Salesforce. In parallel is there any way I can access the Unleashed fields so that I can compare which products are not there in Unleashed which are already there in Salesforce.
 
Hello All,

I am trying to create a community user, i went through the folowing steps:
1. Created an account.
2. Created a contact
3. On the contact detail page, clicked on 'Manage external user' and created a user.

The issue is that when the external user is created, that external user is not receiving the welcome email or the reset password email. 
Hi,
I am creating a signin page in php using heroku, I have created a custom text(encryption) field in salesforce which i want to decrypt in php in order to compare the user entered data with the decrypted data. How can i achieve this?Kindly help if anyone has solution for the same.
Thank you in advance!
Hi all,
I want to compare user entered username and password with the salesforce object record and then only allow the user to redirect to homepage . I have written the following code:
<html>
<head>
</head>
<style>
	.container{
		height:350px; 
		width:350px; 
		align:center;
		background-color:white; 
		border: 2px solid white; 
		border-radius:100px;
		margin-left:auto;
		margin-right:auto;
		margin-top:200px;
		position: relative;
		display:block;	
	}
	.inner-container{
		background-color:white;
		height:150px;
		width:275px;
		margin-left:auto;
		margin-right:auto;
		margin-top:15px;
		padding-top:20px;
	}
	.credentials{
		width:100%;
		padding-top:10px;
		border-radius:10px;
		padding-bottom:10px;
	}
	.signin
	{
		color:black;
		margin-left:auto;
		margin-right:auto;
		text-align:center;
	}
</style>
<?php
     $email = $password = "";
?>
<body style="background-color:#04C5F9">
	<div class="container">
		<div class="signin">
			<img src="https://image3.mouthshut.com/images/imagesp/925609709s.jpg" alt="Aress Picture" style="height:90px;width:200px;margin-top:5px;">
	</div>
		<div class="inner-container">
			<form action="home.php" method="post">
				<input type="text" name="emailid" placeholder="Email Id" class="credentials" value="<?php echo $email;?>">
				<input type="password" name="password" placeholder="Password" class="credentials" value="<?php echo $password;?>" style=" margin-top:5%;">

				<input type="submit" name="submit" value="Log In" class="credentials" style=" margin-top:5%; text-align:center; background-color:#04C5F9; color:white; ">				
				<p>Not a member? &ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp; <a href="signup.php" style="color:black;">SignUp Here</a></p>
			</form>
		</div>
	</div>
</body>
</html>
<?php
$db = pg_connect("host=ec2-54-235-212-58.compute-1.amazonaws.com port=5432 dbname=d11ltu6a8ne38d user=pkdtdgarpbsxgk password=8566866e71a89e3f3eadc11f4960e689801bfad888b96279954e1a09f94ba443");
if (!$db) 
{
	echo "An error occurred.\n";
	exit;	
}
$query = "SELECT Email , Password__c FROM salesforce.contact WHERE Email = '$_POST[email]' AND Password__c = '$_POST[password]';";
$result= pg_query($query);	
return $db;	
if(pg_num_rows($result) != 1) {
   echo '<script type="text/javascript">alert("ERROR! Invalid username or password");</script>';
} else {
    echo '<script type="text/javascript">alert("LOGGED IN!");</script>';
}
 ?>
Kindly help if anyone has solution to this.
Thanks in advance.
Hello All,

I have used lightining tabset in which it contains 3 tabs :Leads , Contacts ,Custom Email .I want to display the list of records of leads and contacts But my issue is that initially for default tab I am not able to see the list of records. I am attching the code of the same.
########### COMPONENT########################

<aura:component controller="ContactPagination" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">
    <ltng:require styles="/resource/slds/assets/styles/salesforce-lightning-design-system.css" />
     <aura:attribute name="listOFrecipients" type="SurveyBuilder__SurveyRecipient__c[]"/>
      <aura:attribute name="surveyId" type="String" />
    <aura:attribute name="name" type="string" />
    <aura:attribute type="Contact[]" name="paginationList" />
    <aura:attribute type="Lead[]" name="paginationListLeads" />
    <aura:attribute type="Integer" name="pageNumber" default="1" />
    <aura:attribute type="Integer" name="maxPage" default="1" />
    <aura:attribute type="String" name="CustomEmails"/>
    
     <aura:attribute name="selTabId" type="string"  />
    
    <aura:handler name="change" value="{!v.pageNumber}" action="{!c.renderPageLeads}" />
    
    <aura:handler name="change" value="{!v.pageNumber}" action="{!c.renderPage}" />
    
    <aura:attribute name="myLeadData" type="Object"/>
    
    <aura:attribute name="mydata" type="Object"/>
    
    <aura:attribute name="myLeadColumns" type="List"/>
    <aura:attribute name="mycolumns" type="List"/>
    
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    
    <c:surveyHeader/>
    <div class="body">
        <div class="bodyContainer">
            <div class="black"></div>
            <div class="slds-size_8-of-8 dashbrdblock">
                
                <div class="sectionTitle">
                    Add Recipients to Survey
                </div>
                <div class="Outer-Box">
                    <div id="warn"  >
                        <ui:message title="Warning" severity="warning" >
                            Please select the recipient!
                        </ui:message>
                    </div>
                    <lightning:tabset selectedTabId="{!v.selTabId}" >
                        
                        <lightning:tab label="Lead" onactive="{!c.renderPageLeads}" id="1">
                            <div class="slds-list_horizontal"  style="padding:1%;">
                                <div class="slds-list_horizontal"  >
                                    <ui:inputText label="Name : " value="{!v.name}"/>
                                </div>
                                <div class="slds-list_horizontal"  >
                                    <ui:inputText label="   Email Address : "  value="{!v.name}" />
                                </div>
                                <button type="button" class="slds-button-neutral">Search</button> 
                                
                            </div>
                          
                            <lightning:datatable data="{! v.myLeadData }"
                                                 columns="{! v.myLeadColumns }"
                                                 keyField="id"
                                                 onrowselection="{! c.getSelectedNameOfLeads }"/>
                            <div class="pagination-box" style="float:right;">
                                <c:Pagination currentPageNumber="{!v.pageNumber}" maxPageNumber="{!v.maxPage}" />
                            </div>    
                            
                        </lightning:tab>
                        <lightning:tab label="Contact" onactive="{!c.renderPage}" id="2">
                            
                            <lightning:datatable data="{! v.mydata }"
                                                 columns="{! v.mycolumns }"
                                                 keyField="id"
                                                 onrowselection="{! c.getSelectedNameOfContacts }"/>
                            <div class="pagination-box" style="float:right;">
                                <c:Pagination currentPageNumber="{!v.pageNumber}" maxPageNumber="{!v.maxPage}" />
                            </div>
                        </lightning:tab>    
                        <lightning:tab label="Custom Email" id="3">
                          
                              <lightning:input class="input" name="Email" label="Enter Email" aura:id="listOfEmails" placeholder="Type emails separated by ','"/>
                        <lightning:button variant="brand" label="Save" title="Next" onclick="{! c.saveEmails }"/>

                        </lightning:tab>
                    </lightning:tabset>
                </div>
                 <div class="feild">
                <button type="button" onclick="{!c.sendSurvey}"  class="slds-button-neutral green-btn addnew-btn">Next</button> 
                <!--  <lightning:button onclick="{!c.createSurveyQuestion}" id="{!newSurvey.Id}" class="slds-button-neutral green-btn addnew-btn" label="Next" />-->
                <!--<lightning:button onclick="{!c.navigateToMQuestions}" class="green-btn default-btn" label="Next" />  -->
            </div>
            </div>
             
        </div>
    </div>
</aura:component>


####################### CONTROLLER ##############################

({init: function (cmp, event, helper) {
  
  
    cmp.set('v.myLeadColumns', [
        { label: 'Name', fieldName: 'Name', type: 'text'},
        { label: 'Phone', fieldName: 'Phone', type: 'phone'},
        { label: 'Email', fieldName: 'Email', type: 'email'}
    ]);

    helper.getData(cmp,event,helper);
    this.renderPageLeads(cmp,event,helper);
    
    cmp.set('v.mycolumns', [
        { label: 'Name', fieldName: 'Name', type: 'text'},
        { label: 'Phone', fieldName: 'Phone', type: 'phone'},
        { label: 'Email', fieldName: 'Email', type: 'email'}
    ]);
   
    helper.getData1(cmp,event,helper);

},
  renderPageLeads: function(cmp, event, helper) {
    
      //document.getElementById('warn').style.display = 'none';
 
      var records = cmp.get("v.paginationListLeads"),
         
          pageNumber = cmp.get("v.pageNumber"),
          pageRecords = records.slice((pageNumber-1)*10, pageNumber*10);
      cmp.set("v.myLeadData", pageRecords);
      alert("===>renderPageLeads" +records);
  },
  renderPage: function(cmp, event, helper) {
       document.getElementById('warn').style.display = 'none';
      var records = cmp.get("v.paginationList"),
          
          pageNumber = cmp.get("v.pageNumber"),
          pageRecords = records.slice((pageNumber-1)*10, pageNumber*10);
      cmp.set("v.mydata", pageRecords);
  },
  getSelectedNameOfLeads : function (cmp, event) {
        document.getElementById('warn').style.display = 'none';
      var selectedRows = event.getParam('selectedRows');
      var idx =cmp.get("v.surveyId");
      var action = cmp.get("c.addRecipentsLead");
      action.setParams({ "resObj" : selectedRows,
                        "surveyId":idx});
      action.setCallback(this, function(a) {
          
          var state = a.getState();
          if (state === "SUCCESS") {
              alert("Success Lead");
          }
          else
          {
              alert("Error Lead");
          }

      });
      $A.enqueueAction(action);
      // Display that fieldName of the selected rows
      
  },
  getSelectedNameOfContacts : function (cmp, event) {
            document.getElementById('warn').style.display = 'none';
      var selectedRows = event.getParam('selectedRows');
      var idx =cmp.get("v.surveyId");
      var action = cmp.get("c.addRecipentsContact");
      action.setParams({ "resObj" : selectedRows,
                        "surveyId":idx});
      action.setCallback(this, function(a) {
          
          var state = a.getState();
          if (state === "SUCCESS") {
              alert("Success Contact");
          }
          else
          {
              alert("Error Contact");
          }
          
          
          
      });
      $A.enqueueAction(action);
      // Display that fieldName of the selected rows
      
  },
  getSelectedName: function (cmp, event) {
       document.getElementById('warn').style.display = 'none';
      var selectedRows = event.getParam('selectedRows');
      var idx =cmp.get("v.surveyId");
      var action = cmp.get("c.addRecipentsCustom");
      action.setParams({ "resObj" : selectedRows,
                        "surveyId":idx});
      action.setCallback(this, function(a) {
          
          var state = a.getState();
          if (state === "SUCCESS") {
              alert("Success Contact");
          }
          else
          {
              alert("Error Contact");
          }
          
          
          
      });
      $A.enqueueAction(action);
      
      // Display that fieldName of the selected rows
      //  for (var i = 0; i < selectedRows.length; i++){
      //  alert(JSON.stringify(selectedRows[i]));
      //}
  },
  saveEmails:function(cmp,event){
      document.getElementById('warn').style.display = 'none';
      var listOfEmail=cmp.find("listOfEmails").get("v.value");
      
      // alert(listOfEmail);
      // var selectedRows = event.getParam('selectedRows');
      var idx =cmp.get("v.surveyId");
      var action = cmp.get("c.addRecipentsCustom");
      action.setParams({ "resObj" : listOfEmail,
                        "surveyId":idx});
      action.setCallback(this, function(a) {
          
          var state = a.getState();
          if (state === "SUCCESS") {
              alert("Success ");
          }
          else
          {
              alert("Error ");
          }
          
          
          
      });
      $A.enqueueAction(action);
      
      
  },
  sendSurvey: function(component, event, helper) {
      var idx1 =component.get("v.surveyId");
      var action = component.get("c.getRecipients");
      action.setParams({ 
          "surveyId":idx1});
      action.setCallback(this, function(a) {
          var response=a.getReturnValue();
          alert('So ja varna hastar aa jayega:::::::::'+JSON.stringify(response));
          var state = a.getState();
          if (state === "SUCCESS") {
              alert("Success ");
              if(response.length>0)
              {
                   document.getElementById('warn').style.display = 'none';
                  var evt = $A.get("e.force:navigateToComponent");
                  // var rec=  component.get("v.surveyId");
                  var idx =component.get("v.surveyId");
                  alert("Inside if" +idx);
                  alert("Survey id in create Survey :"+idx);
                  evt.setParams({ componentDef :"SurveyBuilder:sendSurvey" ,
                                 componentAttributes: {
                                     "surveyId": idx
                                 },});
                  evt.fire();
                
              }
              else
              {
                  
                   document.getElementById('warn').style.display = 'block';
              }
          }
          else
          {
              alert("Error ");
          }
          
          
          
      });
      $A.enqueueAction(action);
      
  }
 })



#############################Helper##############################

({
    getData1 : function(cmp,event,helper) {
        var action = cmp.get('c.getLds');
                
        
        action.setCallback(this, $A.getCallback(function (response) {
            
            var state = response.getState();
           
            var records = response.getReturnValue();
			
            cmp.set("v.paginationListLeads", records);

            cmp.set("v.maxPage", Math.floor((records.length+9)/10));
            
           
            
        }));
        $A.enqueueAction(action);
        
    },
    
    renderLeads: function(cmp,event,helper) {
    
      //document.getElementById('warn').style.display = 'none';
 
      var records = cmp.get("v.paginationListLeads"),
         
          pageNumber = cmp.get("v.pageNumber"),
          pageRecords = records.slice((pageNumber-1)*10, pageNumber*10);
      cmp.set("v.myLeadData", pageRecords);
  },
   
    getData : function(cmp) {
        var action = cmp.get('c.getCntcts');
		
        
              var records = cmp.get("v.paginationListLeads"),
         
          pageNumber = cmp.get("v.pageNumber"),
          pageRecords = records.slice((pageNumber-1)*10, pageNumber*10);
      cmp.set("v.myLeadData", pageRecords);
        
        action.setCallback(this, $A.getCallback(function (response) {
            
            var state = response.getState();
           
            var records = response.getReturnValue();
			
            cmp.set("v.paginationList", records);

            cmp.set("v.maxPage", Math.floor((records.length+9)/10));
            
             
           
        }));
        $A.enqueueAction(action);
    },
     
})

############################ Apex ################################

public with sharing class ContactPagination 
{

      @AuraEnabled
    public static List<Contact> getCntcts() {
        List<Contact> contacts =
                [SELECT Id, Name, Phone, Email FROM Contact limit 100];
        //Add isAccessible() check
        return contacts;
    }
    
          @AuraEnabled
    public static List<Lead> getLds() {
        List<Lead> leads =
                [SELECT Id, Name, Phone, Email FROM Lead limit 100];
        //Add isAccessible() check
        return leads;
    }
    @AuraEnabled
    public static void addRecipentsLead(List<Lead> resObj,String surveyId) {
       // SELECT Id, , SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c, , SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c
       for(Lead l :resObj )
       {
           List<SurveyBuilder__SurveyRecipient__c> existingRecipient =[SELECT Id, SurveyBuilder__SurveyId__c, SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c,  SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c where SurveyBuilder__email__c=:l.Email AND SurveyBuilder__SurveyId__c=:surveyId ];
           if(existingRecipient.size()==0){
           SurveyBuilder__SurveyRecipient__c sr = new SurveyBuilder__SurveyRecipient__c();
           sr.Name='xx';
           sr.SurveyBuilder__SurveyId__c=surveyId;
           sr.SurveyBuilder__email__c=l.Email;
           sr.SurveyBuilder__objectId__c=l.Id;
           sr.SurveyBuilder__typeOfRecipient__c='lead';
           sr.SurveyBuilder__Recipient_Name__c=l.Name;
               insert sr;
                 sr.Name=sr.Id;
                update sr;
           }

       }
    }
    
    @AuraEnabled
    public static void addRecipentsContact(List<Contact> resObj,String surveyId) {
        // SELECT Id, , SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c, , SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c
        for(Contact c :resObj )
        {
            List<SurveyBuilder__SurveyRecipient__c> existingRecipient =[SELECT Id, SurveyBuilder__SurveyId__c, SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c,  SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c where SurveyBuilder__email__c=:c.Email AND SurveyBuilder__SurveyId__c=:surveyId ];
            if(existingRecipient.size()==0){
                SurveyBuilder__SurveyRecipient__c sr = new SurveyBuilder__SurveyRecipient__c();
                sr.Name='xx';
                sr.SurveyBuilder__SurveyId__c=surveyId;
                sr.SurveyBuilder__email__c=c.Email;
                sr.SurveyBuilder__objectId__c=c.Id;
                sr.SurveyBuilder__typeOfRecipient__c='contact';
                sr.SurveyBuilder__Recipient_Name__c=c.Name;
                insert sr;
                sr.Name=sr.Id;
                update sr;
            }
            
        }
    }
    
         
    @AuraEnabled
    public static void addRecipentsCustom(List<String> resObj,String surveyId) {
        // SELECT Id, , SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c, , SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c
        for(String s :resObj )
        {
            List<SurveyBuilder__SurveyRecipient__c> existingRecipient =[SELECT Id, SurveyBuilder__SurveyId__c, SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c,  SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c where SurveyBuilder__email__c=:s AND SurveyBuilder__SurveyId__c=:surveyId ];
            if(existingRecipient.size()==0){
                SurveyBuilder__SurveyRecipient__c sr = new SurveyBuilder__SurveyRecipient__c();
                sr.Name='xx';
                sr.SurveyBuilder__SurveyId__c=surveyId;
                sr.SurveyBuilder__email__c=s;
              
                sr.SurveyBuilder__typeOfRecipient__c='custom';
               sr.SurveyBuilder__Recipient_Name__c='Custom Email';
                insert sr;
                  sr.Name=sr.Id;
                update sr;
            }
            
        }
    }
    @AuraEnabled
    public static   List<SurveyBuilder__SurveyRecipient__c> getRecipients(String surveyId) {
        // SELECT Id, , SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c, , SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c
        List<SurveyBuilder__SurveyRecipient__c> existingRecipient =[SELECT Id, SurveyBuilder__SurveyId__c, SurveyBuilder__email__c, SurveyBuilder__objectId__c, SurveyBuilder__typeOfRecipient__c,  SurveyBuilder__Recipient_Name__c, Name FROM SurveyBuilder__SurveyRecipient__c where  SurveyBuilder__SurveyId__c=:surveyId ];
        
        return  existingRecipient;           
    }
    
}

Thank you in advance.!
Hello All,

I am trying to create a community user, i went through the folowing steps:
1. Created an account.
2. Created a contact
3. On the contact detail page, clicked on 'Manage external user' and created a user.

The issue is that when the external user is created, that external user is not receiving the welcome email or the reset password email.