• asg ase
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 6
    Replies
Hi

Below is my code.Send mails to mailid field of contact object to three members at a time. Getting an error. System.EmailException: SendEmail failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Add a recipient to send an email.: []

global class EmailToContactBatch implements Database.Batchable<sObject> 
{
    global database.querylocator start(Database.BatchableContext BC) 
    {
        return Database.getQueryLocator([select id,name,Email from Contact order by Email asc limit 3]);
    }
   
    global void execute(Database.BatchableContext BC, Sobject[] scope) 
    {
        List<Messaging.SingleEmailMessage> lstEmails = new List<Messaging.SingleEmailMessage>();
        for(Contact objContact :(List<contact>) scope) 
        {
            Messaging.SingleEmailMessage objEmail = new Messaging.SingleEmailMessage();
            //Prepare SendToEmail List          
            List<String> lstSendToEmails = new List<String>();
            if(objContact.Email != null) 
            {
                lstSendToEmails.add(objContact.Email);
            }
            objEmail.setToAddresses(lstSendToEmails);
            //Prepare CCEmailList
            List<String> lstCCToEmails = new List<String>();
            if(objContact.Email != null) 
            {
                lstCCToEmails.add(objContact.Email);
            }
            objEmail.setCcAddresses(lstCCToEmails);
            
            //Set Email Subject
            objEmail.setSubject('Testing Emails');
           
           //Set Email Body
            String body = 'Dear Contact,please ready to contact if you have any issues';
            objEmail.setHtmlBody(body);
            lstEmails.add(objEmail);
            
        Messaging.sendEmail(lstEmails);
        }
    }

    global void finish(Database.BatchableContext BC) 
    {
        
    }
}

Thanks In advance
 
Need a detail solution for this question without code. Is their any way to this by salesforce administration?
Create the picklist field, take the different value of the field.
When the picklist value is selected then render the section every time when the picklist value gets saved.
For example: If the picklist field is Game, Value will be cricket, football,...So if cricket is selected then show the new section name cricket in the page layout, and the same for other values.
Hi, I wrote a trigger to prevent the lead duplicates based on the mobile number and Email.

Am wondering to write a test class for the same trigger. My test class was not passed .can anyone give me the suggestion to how to write a flow for the test class.

My Trigger  code

Trigger leaddup17 on lead(before insert, After Update) {


    Set<String> setEmail = new Set<String>();
    Set<String> setnumber = new Set<String>();
    Set<String> setId = new Set<String>();
    
    for (Lead ld: Trigger.new) {
        if (ld.Phone != Null ||  ld.MobilePhone!=Null || ld.Whatsapp_Mobile__c!=Null || ld.Mobile_Additional__c!=Null|| ld.Phone_Additional__c!=Null 
            ){
                    
            setnumber.add(ld.MobilePhone);
            setnumber .add(ld.Whatsapp_Mobile__c);
            setnumber .add(ld.Mobile_Additional__c);
            setnumber .add(ld.Phone);
            setnumber .add(ld.Phone_Additional__c);
           
          }
        
        if (ld.Email!=null || ld.E_Mail_Additional__c!=Null){
            setEmail.add(ld.Email);
             setEmail.add(ld.Email);
             setEmail.add(ld.E_Mail_Additional__c);
            
        }
        setId.add(ld.id);
    }
        
    List<Lead> lstExistingLead = [Select id,Phone,Email,E_Mail_Additional__c,MobilePhone,Whatsapp_Mobile__c,Phone_Additional__c,Mobile_Additional__c from Lead where  ((email in :setEmail or E_Mail_Additional__c in : setEmail ) or
     (Phone in :setnumber or Phone_Additional__c in : setnumber  or Mobile_Additional__c in : setnumber   or Whatsapp_Mobile__c in :setnumber   or
     MobilePhone in : setnumber))    and (id not in :setId)];
    
    map < string, Lead > LeadsMap = new map < String, Lead > ();
   

    for (Lead ld: lstExistingLead) {
        if (ld.Email!=null || ld.E_Mail_Additional__c!=Null || ld.Phone != Null ||  ld.MobilePhone!=Null || ld.Whatsapp_Mobile__c!=Null || ld.Mobile_Additional__c!=Null|| ld.Phone_Additional__c!=Null )
        {
        
            LeadsMap .put(ld.Phone, ld);
             LeadsMap .put(ld.MobilePhone, ld);
              LeadsMap .put(ld.Whatsapp_Mobile__c, ld);
               LeadsMap .put(ld.Phone_Additional__c, ld);
                LeadsMap .put(ld.Mobile_Additional__c, ld);
                LeadsMap .put(ld.Email, ld);
             LeadsMap .put(ld.E_Mail_Additional__c, ld);
                 
        }   
          setId.add(ld.id);
    }

    for (Lead ld: Trigger.new) 
    {
    
    
        if ( Trigger.isInsert &&  ld.Email!=null || ld.E_Mail_Additional__c!=Null &&  ld.Phone == Null ||  ld.MobilePhone==Null || ld.Whatsapp_Mobile__c==Null || ld.Mobile_Additional__c==Null|| ld.Phone_Additional__c==Null 
        
        && ld.Email != trigger.oldMap.get(ld.Id).Email  ||
         ld.E_Mail_Additional__c!= trigger.oldMap.get(ld.Id).E_Mail_Additional__c)
         
        {
            if ((ld.Email != null && LeadsMap .get(ld.Email) != null) || (ld.E_Mail_Additional__c!= null && LeadsMap .get(ld.E_Mail_Additional__c) != null) )
             {
                ld.adderror('Lead already exist with this  Email. You cannot create a duplicate leads.');
            }
        }

        if ( Trigger.isInsert || (ld.Phone != trigger.oldMap.get(ld.Id).Phone) ||
        (ld.MobilePhone!= trigger.oldMap.get(ld.Id).MobilePhone)||
        (ld.Whatsapp_Mobile__c!= trigger.oldMap.get(ld.Id).Whatsapp_Mobile__c)||
        (ld.Mobile_Additional__c!= trigger.oldMap.get(ld.Id).Mobile_Additional__c)||
        (ld.Phone_Additional__c!= trigger.oldMap.get(ld.Id).Phone_Additional__c))
        {
            if ((ld.Phone != null && LeadsMap.get(ld.Phone) != null) ||
           ( ld.MobilePhone!= null && LeadsMap.get(ld.MobilePhone) != null)||
            (ld.Whatsapp_Mobile__c!= null && LeadsMap.get(ld.Whatsapp_Mobile__c) != null)||
            (ld.Mobile_Additional__c!= null && LeadsMap.get(ld.Mobile_Additional__c) != null)||
            (ld.Phone_Additional__c!= null && LeadsMap.get(ld.Phone_Additional__c) != null)) {
                ld.adderror('Lead already exist with this Phone Number . You cannot create a duplicate leads.');
            }
            setId.add(ld.id);
        }
        
        
        
         if ( (Trigger.isupdate  && (ld.Email!=Null || ld.E_Mail_Additional__c!=Null)) && ((ld.Email != trigger.oldMap.get(ld.Id).Email ) ||
        (ld.E_Mail_Additional__c!= trigger.oldMap.get(ld.Id).E_Mail_Additional__c)))
         
        {
            if ((ld.Email != null && LeadsMap .get(ld.Email) != null) || (ld.E_Mail_Additional__c!= null && LeadsMap .get(ld.E_Mail_Additional__c) != null) )
             {
                ld.adderror('Lead already exist with this  Email. You cannot create a duplicate leads.');
            }
        }

        if ((Trigger.isupdate && (ld.Phone!=Null ||ld.MobilePhone!=Null ||ld.Whatsapp_Mobile__c!=Null || ld.Mobile_Additional__c!=Null ||
     ld.Phone_Additional__c!=Null)) &&  ((ld.Phone != trigger.oldMap.get(ld.Id).Phone) ||
        (ld.MobilePhone!= trigger.oldMap.get(ld.Id).MobilePhone)||
        (ld.Whatsapp_Mobile__c!= trigger.oldMap.get(ld.Id).Whatsapp_Mobile__c)||
        (ld.Mobile_Additional__c!= trigger.oldMap.get(ld.Id).Mobile_Additional__c)||
        (ld.Phone_Additional__c!= trigger.oldMap.get(ld.Id).Phone_Additional__c)))
        {
            if ((ld.Phone != null && LeadsMap.get(ld.Phone) != null) ||
           ( ld.MobilePhone!= null && LeadsMap.get(ld.MobilePhone) != null)||
            (ld.Whatsapp_Mobile__c!= null && LeadsMap.get(ld.Whatsapp_Mobile__c) != null)||
            (ld.Mobile_Additional__c!= null && LeadsMap.get(ld.Mobile_Additional__c) != null)||
            (ld.Phone_Additional__c!= null && LeadsMap.get(ld.Phone_Additional__c) != null)) {
                ld.adderror('Lead already exist with this Phone Number . You cannot create a duplicate leads.');
            }
            
            setId.add(ld.id);
        }
        
    }
    
}
 
Hi!

I'm currently trying to work my way through the Trailhead "Get Started with Hybrid Development", but am having problems when I attempt to "forcedroid create".

When it gets to "Installing "cordova-plugin-whitelist" for android" it fails with:
 
Failed to install 'cordova-plugin-whitelist':TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.join (path.js:466:7)
at D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\lib\check_reqs.js:177:42
at _fulfilled (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:796:13)
at D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:857:14
at runSingle (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:137:13)
at flush (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
Failed to restore plugin "cordova-plugin-whitelist" from config.xml. You might need to try adding it again. Error: TypeError: Path must be a string. Received undefined



This error is not imediately fatal, but after a time I see:
 
Installing "cordova-plugin-whitelist" for android
Failed to install 'cordova-plugin-whitelist':TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.join (path.js:466:7)
at D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\lib\check_reqs.js:177:42
at _fulfilled (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:796:13)
at D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:857:14
at runSingle (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:137:13)
at flush (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
Failed to install 'com.salesforce':TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.join (path.js:466:7)
at D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\lib\check_reqs.js:177:42
at _fulfilled (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:796:13)
at D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:857:14
at runSingle (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:137:13)
at flush (D:\tutorials\AndroidStudioProjects\THA\platforms\android\cordova\node_modules\q\q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
D:\tutorials\AndroidStudioProjects
forcedroid create failed

Command failed: cordova plugin add https://github.com/forcedotcom/SalesforceMobileSDK-CordovaPlugin#v5.0.0 --force
Error: Path must be a string. Received undefined



Whereas, this last bit is fatal.

FWIW,
OS: Windows XP SP3
Java: 1.8.0_121
Node: 5.12.0
Npm: 4.2.0
Cordovoa: 6.5.0

ANDROID_HOME: C:\devtools\Android\sdk
ANDROID_SDK_HOME: C:\devtools\Android\sdk
JAVA_HOME: C:\devtools\Java\jdk1.8.0_121
JDK_HOME: %JAVA_HOME%
JRE_HOME: %JAVA_HOME%\jre
CLASSPATH: .;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib
User PATH: %JAVA_HOME%\bin;C:\Documents and Settings\Brian Kessler\Application Data\npm
System PATH: C:\Documents and Settings\All Users\Application Data\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Pinnacle\Shared Files\InstantCDDVD\;C:\WINXPSP3\system32\WindowsPowerShell\v1.0;C:\Program Files\Skype\Phone\;C:\Program Files\Kensington\TrackballWorks;C:\devtools\Git\cmd;C:\devtools\Git\GitExtensions\;C:\devtools\nodejs\;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools

Any ideas what is wrong or how to fix this?
I am stuck at  this point:

User-added image
I just want to know what is going to be the syntax for resetting the newItem value provider with a Camping_Item__c sObject??

My Code is as follows:

(1) campingList Component:
 
<aura:component >
	
    <aura:attribute name="newItem" type="Camping_Item__c"
     default="{ 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Quantity__c': 0,
                    'Price__c': 0,
                    'Packed__c': false }"/>
    
    <aura:attribute name="items" type="Camping_Item__c[]"/>
    
    <ol>
    <li>Bug Spray</li>
    <li>Bear Repellant</li>
    <li>Goat Food</li>
    </ol>
    
    <!-- CREATE NEW ITEM FORM -->
    <form class="slds-form--stacked">

      <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputText aura:id="itemname" label="Name"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Name}"
                  required="true"/>
          </div>
     </div>

     <div class="slds-form-element slds-is-required">
          <div class="slds-form-element__control">
              <ui:inputNumber aura:id="quantity" label="Quantity"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Quantity__c}"
                  required="true"/>

          </div>
      </div>

      <div class="slds-form-element">
          <div class="slds-form-element__control">
              <ui:inputCurrency aura:id="price" label="Price"
                  class="slds-input"
                  labelClass="slds-form-element__label"
                  value="{!v.newItem.Price__c}"
                  />
          </div>
      </div>

      <div class="slds-form-element">
          <ui:inputCheckbox aura:id="packed" label="Packed?"
              class="slds-checkbox"
              labelClass="slds-form-element__label"
              value="{!v.newItem.Packed__c}"/>
      </div>

      <div class="slds-form-element">
          <ui:button label="Create Camping Item"
              class="slds-button slds-button--brand"
              press="{!c.clickCreateItem}"/>
      </div>

    </form>
    <!-- / CREATE NEW ITEM FORM -->
    
   

    <div class="slds-card slds-p-top--medium">
        <header class="slds-card__header">
            <h3 class="slds-text-heading--small">Items</h3>
        </header>
        
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="items">
                    <c:campingListItem item="{!item}"/>
                </aura:iteration>
            </div>
        </section>
    </div>

</aura:component>

(2) Controller code:
 
({
    clickCreateItem: function(component, event, helper) {

        // Simplistic error checking
        var validItem = true;

        // Name must not be blank
        var nameField = component.find("itemname");
        var itemname = nameField.get("v.value");
        if ($A.util.isEmpty(itemname)){
            validItem = false;
            nameField.set("v.errors", [{message:"Item name can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }
        
        // Quantity must not be blank
        var quantityField = component.find("quantity");
        var quantity = nameField.get("v.value");
        if ($A.util.isEmpty(quantity)){
            validItem = false;
            quantityField.set("v.errors", [{message:"Quantity can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }

        var priceField = component.find("price");
        var price = priceField.get("v.value");
        if ($A.util.isEmpty(price)){
            validItem = false;
            priceField.set("v.errors", [{message:"Price can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }


        if(validItem){
            var newItem = component.get("v.newItem");
            console.log("Create item: " + JSON.stringify(newItem));
            //helper.createItem(component, newItem);
            //        var theItems = component.get("v.items");
 
        // Copy the expense to a new object
        // THIS IS A DISGUSTING, TEMPORARY HACK
        var newItem = JSON.parse(JSON.stringify(item));
 
        console.log("Items before 'create': " + JSON.stringify(theItems));
		theExpenses.push(newItem);
		component.set("v.expenses", theItems);
		console.log("Items after 'create': " + JSON.stringify(theItems));
        theItems.push(newItem);
        component.set("v.items", theItems);
        
        }
    }
})

 

Hello,

 

I am new to SalesForce. We are trying it out to see if it is what we are looking for.  We have already created sku's on our website to pass through to SalesForce when a payment is complete.  I have set up an auto email to send to customers with their billing address, ammount etc.  What is throwing me for a loop is this. We have multiple sku's on our site as we sell hundreds of products.  What I am trying to do is add a description with the sku. So when customer "A" orders 1 Raspberry Ketone from our site right now it passes as 1:RBKVTL. I have this added to the email already. What I want to add is somethign like "If the sku shipped contains RBKVTL description is "Raspberry Ketone". But I need to do this for all of my products.  This is what I have so far:

 

IF(CONTAINS(Sku_Shipped_1__c, "green"), "Green Coffee", "Green Coffee") 

IF(CONTAINS(Sku_Shipped_1__c, "RBKVTL"), "Raspberry Ketone", "Raspberry Ketone")

 

This is obviously wrong as every email passes through "Green Coffee Rapsberry Ketone" no matter what they order.

 

Thanks in advance for the help, please be gentle with me :)

 

Sadie

  • July 09, 2013
  • Like
  • 0