• Mark Rutter
  • NEWBIE
  • 29 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 12
    Replies
I am using a URL to start my Flow and am assigning varibles from that URL:

https://na17.salesforce.com/flow/Get_Inquiry?InquiryID={!Inquiry__c.Id}
&FirstName={!Inquiry__c.First_Name__c}
&LastName={!Inquiry__c.Last_Name__c}
&Email = {!Inquiry__c.Email__c}
&ActiveUser = {!$User.Id}
&retURL=a04/o


The email field in the flow in not populated.  Any idea why?
Also my attempt to get the Current User is not working.
I want to initiate a Flow from a button on a Custom Object.  How do I capture the ID of that Custom Object record and be able to use it in the Flow?
I want to Call an Apex Class from the Process Builder when the value of a field changes to a specific value.

How do I get the ID of the Current Record in the Apex Class? 
I have a custom object with a lookup field (to another custom object) called Listing and a formula field that returns text.  

I thought that both of these were searchable fields, but they do not appear to be.  Is that correct?
This org uses Survey Gizmo to push information collected from a reservation form, creating a new record on a custom object.

I have a very simple Process built with the Process Builder that looks at a picklist field on this newly created record and updates a text field.
When this process is activated, new records are not created by Survey Gizmo and I get the following error from Survey Gizmo:

O:8:"stdClass":3:{s:6:"errors";O:8:"stdClass":3:{s:6:"fields";N;s:7:"message";s:189:"The record couldn�t be saved because it failed to trigger a flow. <br>A flow trigger failed to execute the flow with version ID 301U00000004KZ5. <br/> Contact your administrator for help.";s:10:"statusCode";s:17:"UNKNOWN_EXCEPTION";}s:2:"id";N;s:7:"success";b:0;}

This looks like a flow trigger error.  There are no flows in this org and no workflow rules or Processes that ask to trigger a flow.

Ideas?
I would like to use Visualforce and/or Apex to merge fields into a MS Word merge document template then convert the merged document into a PDF file and attach it to an email.

Anyone know how to do this?
I am experimenting with sending emails with attachments and get the this error message when I run the following code:
System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, Invalid template id.: []

Suggestions?

public class EmailManager {

    // Public method
    public void sendMail(String address, String subject, String body) {
        // Create an email message object
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {address};
        //List<String> docid=new List<String>{'015o00000017GD1'}; // Give the document ID here
        mail.setToAddresses(toAddresses);
        mail.setSubject(subject);
        mail.setPlainTextBody(body);
        //mail.setDocumentAttachments(docid);
        mail.setTargetObjectId('003o0000005g1v8');
        mail.setTemplateID('01Ho0000000TQmj');
        mail.setSaveAsActivity(false);
        
        // Pass this email message to the built-in sendEmail method 
        // of the Messaging class
        Messaging.SendEmailResult[] results = Messaging.sendEmail(
                                 new Messaging.SingleEmailMessage[] { mail });
        
        // Call a helper method to inspect the returned results
        inspectResults(results);
    }
    
    // Helper method
    private static Boolean inspectResults(Messaging.SendEmailResult[] results) {
        Boolean sendResult = true;
        
        // sendEmail returns an array of result objects.
        // Iterate through the list to inspect results. 
        // In this class, the methods send only one email, 
        // so we should have only one result.
        for (Messaging.SendEmailResult res : results) {
            if (res.isSuccess()) {
                System.debug('Email sent successfully');
            }
            else {
                sendResult = false;
                System.debug('The following errors occurred: ' + res.getErrors());                 
            }
        }
        
        return sendResult;
    }

}
I want to initiate a Flow from a button on a Custom Object.  How do I capture the ID of that Custom Object record and be able to use it in the Flow?
I want to initiate a Flow from a button on a Custom Object.  How do I capture the ID of that Custom Object record and be able to use it in the Flow?
I want to Call an Apex Class from the Process Builder when the value of a field changes to a specific value.

How do I get the ID of the Current Record in the Apex Class? 
I'm new to trying to use the @InvocableMethod with the process builder and could use a little guidance as I'm not finding the salesforce examples all that helpful.
My class with the method is below:
public without sharing class CM_KeyReplacementEmailSender {
	
	private static String displayName	= 'claims@maximusautogroup.com';
	private static String replyEmail = 'claims@maximusautogroup.com';
	
	@InvocableMethod	
	public static void send(List<ID> id){
		
		List<MG_Claim_Issue__c > iss = [SELECT ID, Name, Contact_Email__c, MAG_Claim__r.Name, Customer_Name__c, Where_will_repair_occur__c FROM MG_Claim_Issue__c WHERE ID =:id];
		Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); 
		
		String claimNum = iss[0].MAG_Claim__r.Name;
		String issNum = iss[0].Name;
		
		String subject = 'Information regarding open claim with Maximus Auto Group # ' + claimNum;
		
    	String address = iss[0].Contact_Email__c;
    	String[] toAddress = address.split(':', 0);
    	
    	email.setSubject(subject);
		email.setToAddresses(toAddress);
    	email.setSenderDisplayName(displayName);
    	email.setReplyTo(replyEmail);
    	
    	Note note = new Note();
	 	note.Title = 'Email RE: '+ issNum + ' (' + DateTime.now() + ')';
		note.ParentId = iss[0].Id;	
			
    	if(iss[0].Where_will_repair_occur__c == 'Selling Dealer'){
               
        	// Sets the paramaters of the email
			email.setHtmlBody('<p>Test</p>');
    		
    		
			}
		else{
			// Sets the paramaters of the email
			
			email.setHtmlBody('<p>Test2</p>');
    		
			
			}
			// Sends the email
			Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email}); 	
			note.Body = email.plainTextBody;
			insert note;
			
			
			}

}
I've gotten it to covered with a test class, but when I try and Invoke it from a process builder condition meant to supply the id variable in a practical test I'm not seeing any results.  I'm wondering what I may be missing and would appreciate any insight.
 
I have a custom object with a lookup field (to another custom object) called Listing and a formula field that returns text.  

I thought that both of these were searchable fields, but they do not appear to be.  Is that correct?
I would like to use Visualforce and/or Apex to merge fields into a MS Word merge document template then convert the merged document into a PDF file and attach it to an email.

Anyone know how to do this?
I am experimenting with sending emails with attachments and get the this error message when I run the following code:
System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, Invalid template id.: []

Suggestions?

public class EmailManager {

    // Public method
    public void sendMail(String address, String subject, String body) {
        // Create an email message object
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {address};
        //List<String> docid=new List<String>{'015o00000017GD1'}; // Give the document ID here
        mail.setToAddresses(toAddresses);
        mail.setSubject(subject);
        mail.setPlainTextBody(body);
        //mail.setDocumentAttachments(docid);
        mail.setTargetObjectId('003o0000005g1v8');
        mail.setTemplateID('01Ho0000000TQmj');
        mail.setSaveAsActivity(false);
        
        // Pass this email message to the built-in sendEmail method 
        // of the Messaging class
        Messaging.SendEmailResult[] results = Messaging.sendEmail(
                                 new Messaging.SingleEmailMessage[] { mail });
        
        // Call a helper method to inspect the returned results
        inspectResults(results);
    }
    
    // Helper method
    private static Boolean inspectResults(Messaging.SendEmailResult[] results) {
        Boolean sendResult = true;
        
        // sendEmail returns an array of result objects.
        // Iterate through the list to inspect results. 
        // In this class, the methods send only one email, 
        // so we should have only one result.
        for (Messaging.SendEmailResult res : results) {
            if (res.isSuccess()) {
                System.debug('Email sent successfully');
            }
            else {
                sendResult = false;
                System.debug('The following errors occurred: ' + res.getErrors());                 
            }
        }
        
        return sendResult;
    }

}