• jameskCA
  • NEWBIE
  • 35 Points
  • Member since 2016
  • Cloud Attain

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 18
    Replies
Hello all,
I'm troubleshooting lead submissions from a wordpress website with Formidable plugin.  According to formidable (https://formidableforms.com/downloads/salesforce/) they are using REST API.  

So, my issue is, when leads come from this website it's using the lead assignment rules - which is great for new leads.  However, we have one form that does an update based on email address.  This works, but it also triggers the assignment rules and a lead that's already been assigned via other processes get's reassigned back to a queue based on running through the assignment rules again.

What I'm wanting to do is verify how it's doing this (how it's running the assignment rules) but I'm not really sure where to look.  E.G. is that a flag that is being set by the formidable plugin? Any info would be much appreciated.
I recently ran into an Apex unexpected exception error that I believe is related to permissions related to deleting attachments.  The process is, when an opportunity is set to a certain stage (converted to project) it creates a project and, among other things, moves all the attachments from the opportunity to the project via Apex and then deletes the attachments from the opportunity.

Here is the error in the debug log:

11:34:10.365 (2365851365)|DML_BEGIN|[98]|Op:Delete|Type:Attachment|Rows:5 11:34:10.365 (2365868983)|LIMIT_USAGE|[98]|DML|3|150 11:34:10.365 (2365882912)|LIMIT_USAGE|[98]|DML_ROWS|11|10000 11:34:10.365 (2365901258)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:24 11:34:10.365 (2407602848)|DML_END|[98] 11:34:10.365 (2407856725)|EXCEPTION_THROWN|[98]|System.DmlException: Delete failed. First exception on row 0 with id 00P1C00003o9HWfUAM; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: [] 11:34:10.365 (2408457394)|HEAP_ALLOCATE|[98]|Bytes:161 11:34:10.365 (2408509370)|METHOD_EXIT|[71]|01p15000007Y5uA|ProjectTriggerHandler.bulkAfter() 11:34:10.365 (2408531750)|METHOD_EXIT|[27]|01p15000007Y5uD|TriggerFactory.execute(ITrigger) 11:34:10.365 (2408544364)|SYSTEM_MODE_EXIT|false 11:34:10.365 (2408558460)|METHOD_EXIT|[3]|01p15000007Y5uD|TriggerFactory.createHandler(Schema.SObjectType) 11:34:10.365 (2409077931)|FATAL_ERROR|System.DmlException: Delete failed. First exception on row 0 with id 00P1C00003o9HWfUAM; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: [] Class.ProjectTriggerHandler.bulkAfter: line 98, column 1 Class.TriggerFactory.execute: line 71, column 1 Class.TriggerFactory.createHandler: line 27, column 1 Trigger.ProjectTrigger: line 3, column 1 11:34:10.365 (2409210634)|FATAL_ERROR|System.DmlException: Delete failed. First exception on row 0 with id 00P1C00003o9HWfUAM; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: []

The id in the error is for an attachment on the opportunity.  

I'm not a developer but am managing this salesforce instance.  My understanding was that Apex ran as at a system privilege level but the error makes it seem like the DML statement is running with the user permission of the user that saves the record.  Is there a way to make it so this particular Apex trigger runs with elevated privileges so we don't need to give this user more privileges or change the role hierarchy?  
 
We have a trigger that runs on the lead before insert and before update.  Depending on whether it's a new record or updated record, it updates the lead owner differently.  I recently found out that it was running multiple times on each save of a record (or creation).  I'm trying to figure out why but I'm very new to apex and trying to figure out the best way to debug this.

We have a few managed packages that run on the lead as well and one other apex trigger that runs on after update but I'm not sure how to figure out what may be causing this particular trigger to run more than once.

I was able to determine it is running so many times with some debug statements, creating a new record, and seeing the debug statement 5 times (when it should only run once).  

Thanks in advance.  
I'm trying to create a schedule to run an email class we have.  I don't think I'm understanding the schedulable class and where / when you invoke the system.schedule method.  

I have an email class that works fine if you run with execute anonymous. 
CommissioningFollowup CF = new CommissioningFollowup();
My scheduler class uses the following code: 
global class SchedulerCommissioningFollowup implements Schedulable {
	global void execute(SchedulableContext SC) {
		SchedulerCommissioningFollowup SCF = new SchedulerCommissioningFollowup();   
        CommissioningFollowup CF = new CommissioningFollowup();        
		//Will Run Everyday at 00:00 (Midnight)
        String sch = '0 0 0 1/1 * ?';
		String jobID = system.schedule('Commissioning Followup Job', sch, SCF);
	}
}

I thought that would work, but nothing gets scheduled.  Am I supposed to call the system.schedule from my email class?  I'm just not sure how to actually schedule the job.  Thanks in advance.  
 
I'm trying to create an email that sends through apex as we need to setup custom reply to address.  I have an custom html template and was going to use the setTemplateId method to use the template that is already made.  The problem is, the email is based on a custom project object.

The project has a user lookup field for the sales rep.  What I want is to also include the sales rep name, phone number, and email to put at the bottom of the email as their signature.  Those aren't available through the gui template editor.  I tried to just put them in the template anyway like this:
{!Project__c.Sales_Rep__c.Name}
{!Project__c.Sales_Rep__c.Email}
{!Project__c.Sales_Rep__c.Phone}

But the email that sends has blanks for those values.  In apex, I can get all those values through soql.  Is there a way to insert / include them in the template somehow?  Is there a better way to do this?  Thanks in advance.  
I'm currently creating a class that will be called through the apex scheduler.  It will be sending an email using a template.  The email is based on our custom project object which has lookup fields to the salesrep (user) and customer(person account).  I currently having it working with an initial soql statment to get all the proejcts that meet the criteria for the email.
 
public List<Project__c> getCommissionings(){
        //Sales_Rep__c
        //Id, Name, SenderEmail
        List<Project__c> projsWithComm = 
            [SELECT Id, Commissioning_Passed__c, Customer_Email__c, Sales_Rep__c, Customer__c
             FROM Project__c 
             WHERE Disable_Commissioning_Passed_Alert__c != true 
             //AND Commissioning_Passed__c = LAST_N_DAYS:60
        ];
        
        return projsWithComm;
    }

However, I can't use Customer__c in the setTargetObjectId, I need to do an additional account query to get user fields for the signature of the email based on the Sales_Rep__c.  I'm currently doing those in the actual project for loop as I can't figure out a better way to do it.  
 
public void sendEmail(List<Project__c> projsWithComm){
        // First, reserve email capacity for the current Apex transaction to ensure
        // that we won't exceed our daily email limits when sending email after
        // the current transaction is committed.
        Messaging.reserveSingleEmailCapacity(projsWithComm.size());
        
        for(Project__c p : projsWithComm){

            User salesRep = [SELECT Id, Name, SenderEmail From User WHERE Id = : p.Sales_Rep__c];
            Account a = [Select PersonContactId From Account Where Id = :p.Customer__c];

        	// Now create a new single email message object
        	// that will send out a single email to the addresses in the To, CC & BCC list.
        	Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            
            mail.setTemplateId('00X15000000kK6z123');
        	// Strings to hold the email addresses to which you are sending the email.
        	// TODO: Change this address
            String[] toAddresses = new String[] { p.Customer_Email__c };
     
        
        	// Assign the addresses for the To and CC lists to the mail object.
        	mail.setToAddresses(toAddresses);
        
        	// Specify the address used when the recipients reply to the email. 
            mail.setReplyTo( salesRep.SenderEmail );
        
        	// Specify the name used as the display name.
        	mail.setSenderDisplayName('Salesforce Support');
        
        	// Specify the subject line for your email address.
        	//mail.setSubject('Hi! Following up on your commissioning!');
        
        	// Set to True if you want to BCC yourself on the email.
        	mail.setBccSender(true);
            mail.saveAsActivity = false;
            system.debug('CUSTOMER: '+p.Customer__c);
            mail.setTargetObjectId(a.PersonContactId); // Account
 
            mail.setWhatId(p.Id);
			//mail.setTargetObjectId();
            //mail
        	        

	        // Send the email you have created.
        	Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        }

Any ideas on how to do all the SOQL querying before the project loop?  If so, how do I specify the results from the current project loop iteration?  Thanks in advance.  
I'm not understanding how merge fields work when using templates sent via apex.  Here is my current code:
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            Id templateId;
            String[] toAddresses = new String[]{'sales.admin@companydomain.com'};
            email.setToAddresses(toAddresses);
            email.setTargetObjectId(p.Id);
            email.setTemplateId('00X11000000OO2B');
            email.setorgWideEmailAddressId('0D2150000008TCX');
            email.setSaveAsActivity(false);
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

What I'm still really confused about, even after reading the documentation, is what the setTargetObjectId and setWhatId actually do.  

I need to merge several fields from our custom project object, so I was assuming that's what I would use the specific project record id as the setTargetObjectId, but I'm not sure if that's correct as everything I've read says the setTargetObjectId is who you're sending the email to, which in this case is our sales admin.  
So, where / how do I set what the record is that I want to merge fields from, e.g. a specific project record.  Thanks in advance.
I'm hoping someone could provide some sample code or point me to the correct documentation.  I'm not a chatter expert, but I'm trying to accomplish the equivalent of saying @salesAdmin "there's a problem with project 1234." and have it show up in the users chatter feed.  I've done a lot of searching on the web and many of the posts are from 2013 or earlier.  It seems like there have been a lot of changes as all the example code I have tried doesn't seem to work and returns the error Method was removed after version 3x.0

A specific example I tried was:
ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();

messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();

mentionSegmentInput.id = '005RR000000Dme9';
messageBodyInput.messageSegments.add(mentionSegmentInput);

textSegmentInput.text = 'Could you take a look?';
messageBodyInput.messageSegments.add(textSegmentInput);

feedItemInput.body = messageBodyInput;
feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem;
feedItemInput.subjectId = '0F9RR0000004CPw';

ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), feedItemInput, null);
Any ideas?  What is the best way to do this as of the most current release in 2016?
 
We have a customer project object.  THe goal is, after a certain date field is set, to schedule an email to go out ~2 months (60 days) later.  Our custom object is a project for the customer.  The sales rep of the original sale is on the project as a lookup field.  

It's required that the email come FROM the sales rep, so the sales rep can reply directly to the customer.  Is this possible with apex or any other method anyone knows of?  

If so, any advice on how to start would be appreciated.  Thank you.  
I know there are a limited amount of fields you can access using the owner relationship on lead.  What I haven't seen is if there is a workaround to access the user fields based on the ownerid?  

I have a proposal custom object that has a lookup field to a lead.  I need to create a SOQL statement to get sevearl user field values where the user is the owner of the lead related to the proposal.  

I'm doing this in drawloop, so I can only do a SOQL query - I don't think I can use any other code.  Is there a single SOQL statement that can do this? Thanks in advance.  
I'm very new to apex and have been working on a custom 'proposal object.'  The object is related to the lead object through a lookup field.  There are a number of fields the sales person has to fill in on the proposal object in order to generate a proposal (using loop document generation).  Once all fields are filled in and values are calculated, I want to push a number (at least 10) fields back to the related lead.  

I don't really know how to do this.  I'm trying to use the put method, but it doesn't seem to be working.  Here is the relevant code:
 
for(Proposal__c p:Trigger.new){
	        
	        Lead lead = mLead.get(p.Lead__c);

lead.put('Panel_Type__c',p.Panel_Type__c);
Any advice would be appreciated.  Thanks in advance.  
 
I have a very basic method:
public decimal inverterPerformanceFactor(String inverter){
        if(inverter.contains('Enphase')){
            return (104.00/100.00);
            
        }
        else{ return (102.00/100.00);}
    }
Without the decimal places, e.g. 102.00 vs 100, the method would always return 1.  I'm just curious why that is?  Should I always specify a decimal value when doing math in apex?  
 
I have a lot of fields to check for blank values on an object, both numbers and strings.  Would it be best to use the isBlank and convert number fields to strings and use the isBlank method?  Or, just create a new method that would check null, 0, or '' ?

If I created a new method with the above checks, would that work for both string and decimal?  Thanks in advance. 
I'm very new to apex and I'm looking for some advice on how to accomplish the following:

We have 12 "production" formula fields, one for each month.  Here is an example:
IF(ISPICKVAL( Tilt__c ,'10'), 106.17 * System_kW_n__c * Azimuth_Multiplier__c * Inverter_Performance_Factor__c * Solar_Access_Estimate__c , 
IF(ISPICKVAL( Tilt__c ,'20'), 118.27 * System_kW_n__c * Azimuth_Multiplier__c * Inverter_Performance_Factor__c * Solar_Access_Estimate__c , 
IF(ISPICKVAL( Tilt__c ,'30'), 127.59 * System_kW_n__c * Azimuth_Multiplier__c * Inverter_Performance_Factor__c * Solar_Access_Estimate__c ,0)))

I'm trying to create a method that will be a little more elegant than just hard coding all of it with if statements.  I'd like to have a method that is passed all of the above as parameters (e.g. Tilt__c, System_kW_n__c etc...) and based on the tilt value return a collection (list?) with each month (0-12) with the appropriate multiplier value (the 106.17, 118.27, 127.59 from above as an example).

Sorry if the explanation is confusing, again this is new to me.

I'm open to any suggestions, but I was thinking it could be accomplished with nested Lists?  Each month would need to be accessible via 0-12 as the index.  Then within each index I would need to have 3 more keys (10, 20, 30 which is the tilt value) and each of these keys would correspond to a value which is what I actually need to return for each month.  

Any help would be greatly appreciated. 
I have a trigger with some code that references a number field with 18, 0.  My method returns an integer and the quantity variable is an integer, however when I try and use the field value I get the following error:

Method does not exist or incorrect signature: dcSystemSize(String, Decimal)

here is all the relevant code:
Map<String, Integer> panelType = new Map<String,Integer>{'Hyundai 255'=>255,'Hyundai 280'=>280,'Trina 290'=>290,'Hyundai 325'=>325,'SW Mono 280'=>280,'Hyundai 290'=>290};

 public Integer dcSystemSize(String panel, Integer qty){
                    
        Integer panelWattage = panelType.get(panel);
        return ((panelWattage * qty)/1000);
    } 

 for(Proposal__c p:Trigger.new){
 p.System_Size_kW__c = dcSystemSize(p.Panel_Type__c,p.Panel_Qty__c);
}

Is there any way to assign a field to an Integer variable?  Or, are they always decimal?  
I'm very new to Apex so I'm just trying to get pointed in the right direction.  My goal, when a lead is converted and a new opportunity is created, I have mapped a lead "preferred contact method" field to the same field on a contact record.  We have person accounts enabled, so this works for both person accounts and business accounts with contacts.

I also want to carry this field over to the oppotunity that is automatically created.  I'm hoping someone can point me in the right direction either conceptually or with some basic code.  I would think I need to loop through every opportunity trigger:new, figure out if it's a person or business account and put each type of account into a separate list - I'm not sure if that's the best approach or, if it is, what to do next.  

Any help would be appreciated.  
I'm not sure if this is the right place to be posting this question, but I've posted it in the general answers forum and haven't received much feedback.

I have a process that runs on all events that launches a flow.  The flow updates a field  on a related custom project object.  We're currently running into a validation error where the field is trying to get set, but can't without another field being set.  

My question is, how can I notify the user of this?  Currently, they just receive a generic error.  I'd like to let the user know why they can't save an event.  

If possible, I'd like to avoid running the flow altogether as I can check in the flow if the prerequisite field is set or not.  I just don't know how to notify the user at that point.  

Thanks in advance, let me know if you need more info.  
I recently ran into an Apex unexpected exception error that I believe is related to permissions related to deleting attachments.  The process is, when an opportunity is set to a certain stage (converted to project) it creates a project and, among other things, moves all the attachments from the opportunity to the project via Apex and then deletes the attachments from the opportunity.

Here is the error in the debug log:

11:34:10.365 (2365851365)|DML_BEGIN|[98]|Op:Delete|Type:Attachment|Rows:5 11:34:10.365 (2365868983)|LIMIT_USAGE|[98]|DML|3|150 11:34:10.365 (2365882912)|LIMIT_USAGE|[98]|DML_ROWS|11|10000 11:34:10.365 (2365901258)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:24 11:34:10.365 (2407602848)|DML_END|[98] 11:34:10.365 (2407856725)|EXCEPTION_THROWN|[98]|System.DmlException: Delete failed. First exception on row 0 with id 00P1C00003o9HWfUAM; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: [] 11:34:10.365 (2408457394)|HEAP_ALLOCATE|[98]|Bytes:161 11:34:10.365 (2408509370)|METHOD_EXIT|[71]|01p15000007Y5uA|ProjectTriggerHandler.bulkAfter() 11:34:10.365 (2408531750)|METHOD_EXIT|[27]|01p15000007Y5uD|TriggerFactory.execute(ITrigger) 11:34:10.365 (2408544364)|SYSTEM_MODE_EXIT|false 11:34:10.365 (2408558460)|METHOD_EXIT|[3]|01p15000007Y5uD|TriggerFactory.createHandler(Schema.SObjectType) 11:34:10.365 (2409077931)|FATAL_ERROR|System.DmlException: Delete failed. First exception on row 0 with id 00P1C00003o9HWfUAM; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: [] Class.ProjectTriggerHandler.bulkAfter: line 98, column 1 Class.TriggerFactory.execute: line 71, column 1 Class.TriggerFactory.createHandler: line 27, column 1 Trigger.ProjectTrigger: line 3, column 1 11:34:10.365 (2409210634)|FATAL_ERROR|System.DmlException: Delete failed. First exception on row 0 with id 00P1C00003o9HWfUAM; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: []

The id in the error is for an attachment on the opportunity.  

I'm not a developer but am managing this salesforce instance.  My understanding was that Apex ran as at a system privilege level but the error makes it seem like the DML statement is running with the user permission of the user that saves the record.  Is there a way to make it so this particular Apex trigger runs with elevated privileges so we don't need to give this user more privileges or change the role hierarchy?  
 
We have a trigger that runs on the lead before insert and before update.  Depending on whether it's a new record or updated record, it updates the lead owner differently.  I recently found out that it was running multiple times on each save of a record (or creation).  I'm trying to figure out why but I'm very new to apex and trying to figure out the best way to debug this.

We have a few managed packages that run on the lead as well and one other apex trigger that runs on after update but I'm not sure how to figure out what may be causing this particular trigger to run more than once.

I was able to determine it is running so many times with some debug statements, creating a new record, and seeing the debug statement 5 times (when it should only run once).  

Thanks in advance.  
I'm trying to create a schedule to run an email class we have.  I don't think I'm understanding the schedulable class and where / when you invoke the system.schedule method.  

I have an email class that works fine if you run with execute anonymous. 
CommissioningFollowup CF = new CommissioningFollowup();
My scheduler class uses the following code: 
global class SchedulerCommissioningFollowup implements Schedulable {
	global void execute(SchedulableContext SC) {
		SchedulerCommissioningFollowup SCF = new SchedulerCommissioningFollowup();   
        CommissioningFollowup CF = new CommissioningFollowup();        
		//Will Run Everyday at 00:00 (Midnight)
        String sch = '0 0 0 1/1 * ?';
		String jobID = system.schedule('Commissioning Followup Job', sch, SCF);
	}
}

I thought that would work, but nothing gets scheduled.  Am I supposed to call the system.schedule from my email class?  I'm just not sure how to actually schedule the job.  Thanks in advance.  
 
I'm currently creating a class that will be called through the apex scheduler.  It will be sending an email using a template.  The email is based on our custom project object which has lookup fields to the salesrep (user) and customer(person account).  I currently having it working with an initial soql statment to get all the proejcts that meet the criteria for the email.
 
public List<Project__c> getCommissionings(){
        //Sales_Rep__c
        //Id, Name, SenderEmail
        List<Project__c> projsWithComm = 
            [SELECT Id, Commissioning_Passed__c, Customer_Email__c, Sales_Rep__c, Customer__c
             FROM Project__c 
             WHERE Disable_Commissioning_Passed_Alert__c != true 
             //AND Commissioning_Passed__c = LAST_N_DAYS:60
        ];
        
        return projsWithComm;
    }

However, I can't use Customer__c in the setTargetObjectId, I need to do an additional account query to get user fields for the signature of the email based on the Sales_Rep__c.  I'm currently doing those in the actual project for loop as I can't figure out a better way to do it.  
 
public void sendEmail(List<Project__c> projsWithComm){
        // First, reserve email capacity for the current Apex transaction to ensure
        // that we won't exceed our daily email limits when sending email after
        // the current transaction is committed.
        Messaging.reserveSingleEmailCapacity(projsWithComm.size());
        
        for(Project__c p : projsWithComm){

            User salesRep = [SELECT Id, Name, SenderEmail From User WHERE Id = : p.Sales_Rep__c];
            Account a = [Select PersonContactId From Account Where Id = :p.Customer__c];

        	// Now create a new single email message object
        	// that will send out a single email to the addresses in the To, CC & BCC list.
        	Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            
            mail.setTemplateId('00X15000000kK6z123');
        	// Strings to hold the email addresses to which you are sending the email.
        	// TODO: Change this address
            String[] toAddresses = new String[] { p.Customer_Email__c };
     
        
        	// Assign the addresses for the To and CC lists to the mail object.
        	mail.setToAddresses(toAddresses);
        
        	// Specify the address used when the recipients reply to the email. 
            mail.setReplyTo( salesRep.SenderEmail );
        
        	// Specify the name used as the display name.
        	mail.setSenderDisplayName('Salesforce Support');
        
        	// Specify the subject line for your email address.
        	//mail.setSubject('Hi! Following up on your commissioning!');
        
        	// Set to True if you want to BCC yourself on the email.
        	mail.setBccSender(true);
            mail.saveAsActivity = false;
            system.debug('CUSTOMER: '+p.Customer__c);
            mail.setTargetObjectId(a.PersonContactId); // Account
 
            mail.setWhatId(p.Id);
			//mail.setTargetObjectId();
            //mail
        	        

	        // Send the email you have created.
        	Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        }

Any ideas on how to do all the SOQL querying before the project loop?  If so, how do I specify the results from the current project loop iteration?  Thanks in advance.  
I'm not understanding how merge fields work when using templates sent via apex.  Here is my current code:
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            Id templateId;
            String[] toAddresses = new String[]{'sales.admin@companydomain.com'};
            email.setToAddresses(toAddresses);
            email.setTargetObjectId(p.Id);
            email.setTemplateId('00X11000000OO2B');
            email.setorgWideEmailAddressId('0D2150000008TCX');
            email.setSaveAsActivity(false);
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});

What I'm still really confused about, even after reading the documentation, is what the setTargetObjectId and setWhatId actually do.  

I need to merge several fields from our custom project object, so I was assuming that's what I would use the specific project record id as the setTargetObjectId, but I'm not sure if that's correct as everything I've read says the setTargetObjectId is who you're sending the email to, which in this case is our sales admin.  
So, where / how do I set what the record is that I want to merge fields from, e.g. a specific project record.  Thanks in advance.
I'm hoping someone could provide some sample code or point me to the correct documentation.  I'm not a chatter expert, but I'm trying to accomplish the equivalent of saying @salesAdmin "there's a problem with project 1234." and have it show up in the users chatter feed.  I've done a lot of searching on the web and many of the posts are from 2013 or earlier.  It seems like there have been a lot of changes as all the example code I have tried doesn't seem to work and returns the error Method was removed after version 3x.0

A specific example I tried was:
ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();

messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();

mentionSegmentInput.id = '005RR000000Dme9';
messageBodyInput.messageSegments.add(mentionSegmentInput);

textSegmentInput.text = 'Could you take a look?';
messageBodyInput.messageSegments.add(textSegmentInput);

feedItemInput.body = messageBodyInput;
feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem;
feedItemInput.subjectId = '0F9RR0000004CPw';

ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), feedItemInput, null);
Any ideas?  What is the best way to do this as of the most current release in 2016?
 
We have a customer project object.  THe goal is, after a certain date field is set, to schedule an email to go out ~2 months (60 days) later.  Our custom object is a project for the customer.  The sales rep of the original sale is on the project as a lookup field.  

It's required that the email come FROM the sales rep, so the sales rep can reply directly to the customer.  Is this possible with apex or any other method anyone knows of?  

If so, any advice on how to start would be appreciated.  Thank you.  
I'm very new to apex and have been working on a custom 'proposal object.'  The object is related to the lead object through a lookup field.  There are a number of fields the sales person has to fill in on the proposal object in order to generate a proposal (using loop document generation).  Once all fields are filled in and values are calculated, I want to push a number (at least 10) fields back to the related lead.  

I don't really know how to do this.  I'm trying to use the put method, but it doesn't seem to be working.  Here is the relevant code:
 
for(Proposal__c p:Trigger.new){
	        
	        Lead lead = mLead.get(p.Lead__c);

lead.put('Panel_Type__c',p.Panel_Type__c);
Any advice would be appreciated.  Thanks in advance.  
 
I have a lot of fields to check for blank values on an object, both numbers and strings.  Would it be best to use the isBlank and convert number fields to strings and use the isBlank method?  Or, just create a new method that would check null, 0, or '' ?

If I created a new method with the above checks, would that work for both string and decimal?  Thanks in advance. 
I have a trigger with some code that references a number field with 18, 0.  My method returns an integer and the quantity variable is an integer, however when I try and use the field value I get the following error:

Method does not exist or incorrect signature: dcSystemSize(String, Decimal)

here is all the relevant code:
Map<String, Integer> panelType = new Map<String,Integer>{'Hyundai 255'=>255,'Hyundai 280'=>280,'Trina 290'=>290,'Hyundai 325'=>325,'SW Mono 280'=>280,'Hyundai 290'=>290};

 public Integer dcSystemSize(String panel, Integer qty){
                    
        Integer panelWattage = panelType.get(panel);
        return ((panelWattage * qty)/1000);
    } 

 for(Proposal__c p:Trigger.new){
 p.System_Size_kW__c = dcSystemSize(p.Panel_Type__c,p.Panel_Qty__c);
}

Is there any way to assign a field to an Integer variable?  Or, are they always decimal?  
I'm very new to Apex so I'm just trying to get pointed in the right direction.  My goal, when a lead is converted and a new opportunity is created, I have mapped a lead "preferred contact method" field to the same field on a contact record.  We have person accounts enabled, so this works for both person accounts and business accounts with contacts.

I also want to carry this field over to the oppotunity that is automatically created.  I'm hoping someone can point me in the right direction either conceptually or with some basic code.  I would think I need to loop through every opportunity trigger:new, figure out if it's a person or business account and put each type of account into a separate list - I'm not sure if that's the best approach or, if it is, what to do next.  

Any help would be appreciated.  
I'm not sure if this is the right place to be posting this question, but I've posted it in the general answers forum and haven't received much feedback.

I have a process that runs on all events that launches a flow.  The flow updates a field  on a related custom project object.  We're currently running into a validation error where the field is trying to get set, but can't without another field being set.  

My question is, how can I notify the user of this?  Currently, they just receive a generic error.  I'd like to let the user know why they can't save an event.  

If possible, I'd like to avoid running the flow altogether as I can check in the flow if the prerequisite field is set or not.  I just don't know how to notify the user at that point.  

Thanks in advance, let me know if you need more info.  
Hi,

I have verified an email in organization wide email address and sending email from apex class. This is working fine. But for one user it is throwing following exception,


System.EmailException: SendEmail failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_OR_READONLY, Not profiled to access this Org-wide Email Address: []