• SFDC@Error
  • NEWBIE
  • 34 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 4
    Likes Received
  • 0
    Likes Given
  • 183
    Questions
  • 75
    Replies
Hi All,
Is it possible to run approval process based on line item in opportunity .
Hi All,
How can i send emil with multiple attachment files.I have developed a controller for mail sending ,working fine.But unable to attach multiple files with the mail....
Hi All,
How can i send an email with default email template using visual force page? 
Hi All
I have created a controller and vf page.when i am creating record file attaching in notes and attachment with static name.like test.pdf.How can i create dynamic name for pdf name for example object__c.Name.pdf.
public class AttachPDF {

private final Id recordId;

public AttachPDF_Controller(ApexPages.StandardController controller) {
recordId =     controller.getId();
system.debug('inside AttachPDF');
    }
    @future(callout = true)
     public static void save(Id AccId, String acctName){
    system.debug('inside AttachPDF save');
        PageReference pdf = new PageReference('/apex/PDFPage?id='+Accid);
         pdf.setRedirect(true);
         pdf.getParameters().put('Id',AccId);
         Blob b= pdf.getContent();
        
        Attachment formAttach = new Attachment();
           
             formAttach.Name = 'test'+'.pdf';
             formAttach.body = b;
             formAttach.ContentType='application/pdf';
             formAttach.parentId =AccId;
             insert formAttach; 
              
        
    }

}
Hi All,
I have developed a component for mass email sending .but i am getting an error like This page has an error. You might just need to refresh it. Aura.loadComponent(): Failed to initialize the application. An internal server error has occurred Error ID: 1863109829-477750 (412317498).
User-added image
<aura:component controller="ListEmailOppCntrlr" implements="force:hasRecordId,flexipage:availableForAllPageTypes,force:lightningQuickActionWithoutHeader" access="global">
    <aura:handler name="init" value="{!this}" action="{!c.loadComponent}"/> 
    <aura:attribute name="errorMsg" type="String" description=""/>
    <aura:attribute name="shoMsg" type="boolean" default="false" description=""/>
    <aura:attribute name="shwSucesMsg" type="boolean" default="false" description=""/>
    <aura:attribute name="showLoader" type="boolean" default="false" description=""/> 
    <aura:attribute name="Case" type="Case" 
                    default="{ 'sobjectType': 'Case', 'SampleRichText__c':''}"/>
    
    <aura:attribute name="disableTemplate" type="boolean" default="false" description=""/>
    <aura:attribute name="selTempl" type="String" description=""/>
    <aura:attribute name="templates" type="EmailTemplate[]" default="[]"/>
    <aura:attribute name="addnlEmails" type="String" default="" description=""/>
    <aura:attribute name="subjTxt" type="String" default="" description=""/>
    <aura:attribute name="msgReview" type="String" default="" description=""/>
    <aura:attribute name="accIds" type="String" access="GLOBAL" default="" description=""/>
    <aura:attribute name="oppIds" type="String" access="GLOBAL" default="" description=""/>
    <aura:attribute name="accRecords" type="sObject[]" default="[]" />
    <aura:attribute name="templDetail" type="EmailTemplate" default="{}" />
    
    <div class="slds-page-header" role="banner">
        <div class="slds-grid">
            <div class="slds-col slds-has-flexi-truncate">
                <!-- SEARCH AREA -->
                <p class="slds-text-title--caps slds-line-height--reset">
                    
                    <span title="lead Standard Icon">
                        
                    </span>&nbsp;&nbsp;Send Email</p>
                <!-- / SEARCH AREA -->
            </div>
            
        </div>
    </div>
    
    
    
    <br/><br/>
    <!-- Connection 1 Section -->
    <div class="slds-grid slds-grid_vertical">
        <div class="slds-box slds-box--small slds-theme--shade slds-text-align--left">Email Message</div>
        <br/>
        <div class="slds-col">
            
            <div class="slds-form-element slds-size--1-of-1">
                <!-- <label class="slds-form-element__label" for="input-02">Recipients<span color="red"><b>*</b></span></label> -->
                
                <!--  <input type="Text" autocomplete="off" style="border-left:4px solid red;" value=""  class="slds-input" /> -->
                
                                <c:reUsableMultiSelectLookup objectAPIName="account"
                                             IconName="standard:account"
                                             lstSelectedRecords="{!v.accRecords}"
                                             label="Recipients" 
                                             />
                

            </div>
            
        </div> <br/><br/>
        
        <div class="slds-col">
            <lightning:select disabled="{!v.disableTemplate}" onchange="{!c.loadTemplate}"  name="SelectDivision" label="Select a Template:" aura:id="templateId" value="{!v.selTempl}">
                <option text="None" value=""/>
                
                <aura:iteration items="{!v.templates}" var="item">
                    <option text="{!item.Name}" value="{!item.Id}"/>
                </aura:iteration> 
            </lightning:select>
        </div> <br/><br/> 
        
        <div class="slds-col">
            <div class="slds-form-element slds-size--1-of-1">
                <label class="slds-form-element__label" for="input-02">Subject:</label>
                
                <input id="subjMatter" type="Text" autocomplete="off" value="{!v.subjTxt}"  class="slds-input" />
            </div>  
            
        </div><br/><br/>
        
        <div class="slds-col" aura:id="emailBodyDiv">   
            <div class="slds-form-element slds-size--1-of-1">
                <label class="slds-form-element__label" for="input-02">Content :</label>
                <span></span>
                <force:inputField class="richTxt" value="{!v.Opportunity.SampleRichText__c}"/>
            </div>
        </div><br/><br/>
        
        <aura:if isTrue="{!!empty(v.selTempl)}" >
            <lightning:textarea name="myTextArea" value="{!v.templDetail.Body}" 
                                label="Content:" maxlength="700" 
                                class="txtAreaCls" disabled="true" />
            <br/><br/>
        </aura:if>
        
        
    </div>    
    
    <br/>
    
    <!-- Error message area -->
    
    <br/><br/>
    <aura:if isTrue="{!v.shoMsg}" >
        <ui:message aura:id="errPanel"  title="Error" severity="error" closable="false">
            {!v.errorMsg}
        </ui:message>
        <br/><br/>
    </aura:if>
    
    <aura:if isTrue="{!v.shwSucesMsg}" >
        <ui:message aura:id="errPanel"  title="Success!" severity="confirm" closable="false">
            Email has been sent!
        </ui:message>
        <br/><br/>
    </aura:if>	
    
    <!-- Buttons and Loader section -->
    <div class="slds-align_absolute-center " style="padding:2%;">
        
        <lightning:button variant="brand" label="Send Email" onclick="{!c.sendEmailAction}" />
        
        <input type="button" value="Cancel" class="slds-button slds-button--neutral" onclick="{!c.closeDialog}"/>
        <aura:if isTrue="{!v.showLoader}">
            <div class="demo-only" style="height: 6rem;">
                <div role="status" class="slds-spinner_brand slds-spinner slds-spinner_small">
                    <span class="slds-assistive-text">Loading</span>
                    <div class="slds-spinner__dot-a"></div>
                    <div class="slds-spinner__dot-b"></div>
                </div>
            </div>
        </aura:if>  
        
    </div>     
</aura:component>
 
({
    
     loadComponent : function(component, event, helper) {
        helper.getSelctedAccountsOfOpportunity(component, event);
        helper.getEmailTempaltes(component, event);
        console.log(component.get("v.accIds"));
    }, 
   
    sendEmailAction : function(component, event, helper) {
        helper.sendEmails(component, event);
        
    },
    loadTemplate : function(component, event, helper) {
        helper.getTemplate(component, event);
        
    },
    closeDialog : function(component, event, helper)
    {
        helper.cancelAction(component, event);
    }
    
    
    
    
    
})
 
({
    getEmailTempaltes : function(component, event) {
        var action = component.get("c.getTemplates");
        //action.setParams({"divisionId":selectedDivision});
        
        action.setCallback(this,function(response){
            var loadResponse = response.getReturnValue();
            console.log('templates..!',loadResponse);
            
            if(!$A.util.isEmpty(loadResponse)){
                
                component.set('v.templates',loadResponse);
                
            }
        });
        $A.enqueueAction(action);
    },
    getSelctedAccountsOfOpportunity : function(component, event) {
        
        var accIdsofOpp = component.get("v.accIds");
        
        if(!$A.util.isEmpty(accIdsofOpp)){
            
            var action = component.get("c.getAccountsOfOpportunity");
            action.setParams({"accIds":accIdsofOpp});
            
            action.setCallback(this,function(response){
                var responseVal = response.getReturnValue();
                console.log('responseVal..** ',responseVal);
                
                if(!$A.util.isEmpty(responseVal)){
                    
                    component.set("v.accRecords",responseVal);
                    
                }
            });
            $A.enqueueAction(action);
        }
        
    },
    sendEmails : function(component, event) {
        component.set("v.shoMsg", false);
        component.set("v.showLoader", true);
        var selRec = component.find("lookupRes").get("v.lstSelectedRecords");
        var templateId = component.get("v.selTempl");
        var oppRecIds = component.get("v.oppIds");
        console.log('oppRecIds ', oppRecIds);
        console.log('sel records ', selRec);
        console.log('sel template ', templateId);
        
        //var addnlEmails = document.getElementById("addnlEmail").value;
        
        var subjMatter = document.getElementById("subjMatter").value;
        console.log('subjMatter ',subjMatter);
        var emailBody = !$A.util.isEmpty(component.get("v.Case").SampleRichText__c) ? component.get("v.Case").SampleRichText__c : '';
        console.log('emailBody ',emailBody);
        
        if(!$A.util.isEmpty(selRec) && (!$A.util.isEmpty(emailBody) || !$A.util.isEmpty(templateId)) ){
            
            var accIds = [];
            for (var i = 0; i<selRec.length; i++) {
                accIds.push(selRec[i].PersonContactId);
            }
            console.log('---accIds--- ', accIds);
            var accIdStr = !$A.util.isEmpty(accIds) ? accIds.join() : '';
            console.log('---accIdStr--- ', accIdStr);
            
            if(!$A.util.isEmpty(accIdStr) || !$A.util.isEmpty(addnlEmails)){
                
                console.log('---accIdStr--- ', accIdStr);
                console.log('--Case--', component.get("v.Case"));
                
                var action = component.get("c.sendAnEmailMsg");
                action.setParams({"templateId":templateId,
                                  "accIds":!$A.util.isEmpty(accIdStr) ? accIdStr : '',
                                  "opty":component.get("v.Case"),
                                  "subj" : !$A.util.isEmpty(subjMatter) ? subjMatter : '',
                                  "addnlEmails" : '',
                                  "oppIds" : oppRecIds });
                
                action.setCallback(this,function(response){
                    
                    var emailMsgResp = response.getReturnValue();
                    console.log('--emailMsgResp--', emailMsgResp); //isSuccess  errMsg
                    component.set("v.showLoader", false);
                    
                    if(emailMsgResp.isSuccess){
                        component.set("v.shwSucesMsg", true);
                        this.cancelAction(component, event);
                    }
                    else {
                        component.set("v.shoMsg", true);
                        component.set("v.errorMsg", emailMsgResp.errMsg);
                    }
                    
                });
                $A.enqueueAction(action);
            }
            
            
            
        }
        else {
            component.set("v.showLoader", false);
            component.set("v.shoMsg", true);
            component.set("v.errorMsg", "Please provide Recipient, Template or Email Body");
        }
        
    },
    getTemplate : function(component, event) {
        
        var templId = component.get("v.selTempl");
        component.set("v.showLoader", true);
        if(!$A.util.isEmpty(templId)){
            
            var action = component.get("c.getTemplateDetails");
            action.setParams({"templteId":templId});
            
            action.setCallback(this,function(response){
                component.set("v.showLoader", false);
                var responseVal = response.getReturnValue();
                console.log('responseVal..@getTemplate ',responseVal);
                
                if(!$A.util.isEmpty(responseVal)){
                    
                    component.set("v.templDetail",responseVal);
                    component.set("v.subjTxt",responseVal.Subject);
                    if(!$A.util.hasClass(component.find("emailBodyDiv"), "slds-hide")){
                        
                        $A.util.addClass(component.find("emailBodyDiv"), 'slds-hide'); 
                    }
                    
                }
            });
            $A.enqueueAction(action);
        }
        else {
            component.set("v.showLoader", false);
            if($A.util.hasClass(component.find("emailBodyDiv"), "slds-hide")){
                
                $A.util.removeClass(component.find("emailBodyDiv"), 'slds-hide');
            }
        }
    },
    cancelAction: function(component, event){
        var urlEvent = $A.get("e.force:navigateToURL");
        urlEvent.setParams({
            "url": '/500/o'
        });
        urlEvent.fire()
    }
    
})

 
Hi All

I have a custom object and custom email field. Looking for mass email to selected record using vf page.Any solution.
Hi All,
How can i open child record type page automatically on click of the new button of the child in details page based on parent field value?
I have two record type in the child object.but when i am creating child record from the parent, it should select the record type and create.I want to override this step based on the parent field. that auto-redirects the record type page, no need to select particular record type.
Hi All

How can i send email using lightning component with insert template selection option? I have tried below, but unable to add insert template option. can anyone help me this 
public class EmailSendController {
 @AuraEnabled 
    public static void sendMailMethod(String mMail ,String mSubject ,String mbody){
    
     List<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();     
  
     // Step 1: Create a new Email
       Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    
    // Step 2: Set list of people who should get the email
       List<String> sendTo = new List<String>();
       sendTo.add(mMail);
       mail.setToAddresses(sendTo);
    
    // Step 3: Set who the email is sent from
       mail.setReplyTo('noreply@gmail.com'); // change it with your mail address.
       mail.setSenderDisplayName('salesforce User'); 
    
    // Step 4. Set email contents - you can use variables!
      mail.setSubject(mSubject);
      mail.setHtmlBody(mbody);
    
    // Step 5. Add your email to the master list
      mails.add(mail);
    
  // Step 6: Send all emails in the master list
     Messaging.sendEmail(mails);
   }   
}
 
<aura:component controller="EmailSendController">
   <!--Part 1 [for attribute declare]-->  
   <aura:attribute name="email" type="string"/>
   <aura:attribute name="subject" type="string"/>
   <aura:attribute name="body" type="string"/>
   <aura:attribute name="mailStatus" type="boolean" default="false"/>
   
   <!---Part 2 [header part] -->  
   <div class="slds-page-header" role="banner">
      <h1 class="slds-page-header__title slds-m-right--small slds-align-middle slds-truncate" title="this should match">
         Quick Email Send.
      </h1>
      <div class="slds-text-color--weak">by sfdcMonkey.com</div>
   </div>
 
   <!---Part 3 [message display part] --> 
   <aura:if isTrue="{!v.mailStatus}">
      <div role="alertdialog" tabindex="-1" aria-labelledby="prompt-heading-id" aria-describedby="prompt-message-wrapper" class="slds-modal slds-fade-in-open slds-modal--prompt">
         <div class="slds-modal__container">
            <div class="slds-modal__header slds-theme--error slds-theme--alert-texture">
               <h2 class="slds-text-heading--medium" id="prompt-heading-id">Mail Status</h2>
            </div>
            <div class="slds-modal__content slds-p-around--medium">
               <div>
                  <p>Email Sent successfully to {!v.email}</p>
               </div>
            </div>
            <div class="slds-modal__footer slds-theme--default">
               <button class="slds-button slds-button--brand" onclick="{!c.closeMessage}">Close</button>
            </div>
         </div>
      </div>
      <div class="slds-backdrop slds-backdrop--open"></div>
   </aura:if>
   
   <!---Part 4 [mail fourm part]-->   
   <div class="slds-m-around--medium">
      <div class="slds-container--medium">
         <div class="slds-form--stacked">
            <div class="slds-form-element">
               <label class="slds-form-element__label" for="CC">Email</label>
               <div class="slds-form-element__control">
                  <ui:inputEmail class="slds-input" aura:id="email"  value="{!v.email}" required="true" placeholder="abc@email.com"/>
               </div>
            </div>
            <div class="slds-form-element">
               <label class="slds-form-element__label" for="CC">Subject</label>
               <div class="slds-form-element__control">
                  <ui:inputText class="slds-input" aura:id="subject"  value="{!v.subject}" placeholder="Subject"/>
               </div>
            </div>
            <div class="slds-form-element">
               <label class="slds-form-element__label" for="textareaSample2">Mail Body</label>
               <div class="slds-form-element__control">
                  <lightning:inputRichText aura:id="body" value="{!v.body}" />
               </div>
            </div>
            <div class="slds-form-element">    
               <button class="slds-button slds-button--brand" onclick="{!c.sendMail}">Send</button>
            </div>
         </div>
      </div>
   </div>
</aura:component>
 
({
    sendMail: function(component, event, helper) {
        // when user click on Send button 
        // First we get all 3 fields values 	
        var getEmail = component.get("v.email");
        var getSubject = component.get("v.subject");
        var getbody = component.get("v.body");
        // check if Email field is Empty or not contains @ so display a alert message 
        // otherwise call call and pass the fields value to helper method    
        if ($A.util.isEmpty(getEmail) || !getEmail.includes("@")) {
            alert('Please Enter valid Email Address');
        } else {
            helper.sendHelper(component, getEmail, getSubject, getbody);
        }
    },
 
    // when user click on the close buttton on message popup ,
    // hide the Message box by set the mailStatus attribute to false
    // and clear all values of input fields.   
    closeMessage: function(component, event, helper) {
        component.set("v.mailStatus", false);
        component.set("v.email", null);
        component.set("v.subject", null);
        component.set("v.body", null);
    },
})
 
({
    sendHelper: function(component, getEmail, getSubject, getbody) {
        // call the server side controller method 	
        var action = component.get("c.sendMailMethod");
        // set the 3 params to sendMailMethod method   
        action.setParams({
            'mMail': getEmail,
            'mSubject': getSubject,
            'mbody': getbody
        });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var storeResponse = response.getReturnValue();
                // if state of server response is comes "SUCCESS",
                // display the success message box by set mailStatus attribute to true
                component.set("v.mailStatus", true);
            }
 
        });
        $A.enqueueAction(action);
    },
})

 
Hi All
How can I update and create child record based on the parent? Like in the parent, I have a picklist field with value 1,2,3,4 and Budget Amount is 2000.and in the child there is no record. If I select picklist value 2 and save it will create 2 child record with budget amount 1000 and 1000.but if i select picklist value 4 then it is creating 4 records with budget amount 500,500,500,500 like. Problem is here record is creating new 4 child record .but i want to update existing record and create new 2 records
trigger Pay on Parent__c (before update) {
    Set<Id> ids = new Set<Id>();
     list<child__c> ids1= new list<child__c >();
      for(Opportunity rr : Trigger.new) {
        if (Trigger.oldmap.get(rr.id).Number__c!= Trigger.newmap.get(rr.id).Number__c  ) {
     
            for(integer i = 0; i< integer.valueOf(rr.Number__c); i++){
                child__c c= new child__c();
               
                c.name = rr.Name ;
                c.Parent__c= rr.id;
                c.Pay=rr.Pay/rr.Number__c
                
               
                ids1.add(c);
            }
     }
     }
    
    
    if(!ids1.isEmpty()){
    upsert ids1;
    }       
}

.
Hi All

How can i share the record using apex sharing on the personal group? In user level, i am adding the personal group for sharing the record.is it possible ?
We have several Workflow Rules that create Workflow Tasks x days later than the Rule trigger date.  We would like to create an Apex Trigger that will automatically calculate the day of the week the new Task is due on and if on a weekend, change the date to 2 day later.

I know it's possible to calculate Day of Week in a formula field thanks to this blog post.

I've already read the Apex Language Reference and created some simple Apex Triggers, but I just don't have enough experience working with Apex Triggers to know how to do this.  Any help or samples would be greatly appreciated.

Thanks,

Matt