• GeoLinale
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

Hi All,

 

I needed to send an email notification on opportunities with conditions too complex for a workflow rule, so I created a trigger that checks the conditions and sends the email. I was successful on doing this, but now only problem I have is that the notification needs to be sent from a general address (org wide address), and this address should be available only for the trigger, not for the users. But if I do not add the profiles of the users to the org wide address, I get the following error:

 

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

 

On the other hand, if I give access to the profiles, then the org wide address is available whenever the users want to send any email message.

 

Does anyone know how to use the org wide address in a trigger without providing access to the user’s profile? Any other solution like running the code always under another user (i.e. system admin)?

 

Thanks in advance!

Hi,
We have a piece of Apex code which calls a webservice reads some information from the webservice and updates accounts. 
One of the values it updates is BillingCountry and when the value returned by the webservice is not correct salesforce.com throws an FIELD_INTEGRITY_EXCEPTION.
To fix that I developed a before update and before insert trigger which converts the invalid value to a valid value. Salesforce.com still throws an error.
The exact steps to reproduce are:
1. Turn address picklists on.
  2. Write a Before update, before instert trigger for account:
trigger Account_BIBU on Account(before insert, before update) {   
    Account acct = (Account)trigger.new[0];
    acct.BillingCountry = 'France';
}
   3. Open the developer console => Debug => Execute Anonimous Apex and execute:
   Account acct = [Select Name, BillingCountry, BillingStreet FROM Account WHERE LIMIT 1];
   acct.BillingCountry ='United States of America';
    update acct;
    4. Execute it. It will throw an error.
    5. Now try to execute the below:
        Account acct = [Select Name, BillingCountry, BillingStreet FROM Account LIMIT 1];
        acct.BillingCountry ='United States';
        update acct;
       It executes fine and BillingCountry is France.

Does anyone have any ideas? Is this a bug in salesforce.com? 
As far as I know salesforce.com runs validation rules after before update trigger but in this case they seem to be run before the before update trigger.

Thanks,
Kzmp

Hi All,

 

I needed to send an email notification on opportunities with conditions too complex for a workflow rule, so I created a trigger that checks the conditions and sends the email. I was successful on doing this, but now only problem I have is that the notification needs to be sent from a general address (org wide address), and this address should be available only for the trigger, not for the users. But if I do not add the profiles of the users to the org wide address, I get the following error:

 

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

 

On the other hand, if I give access to the profiles, then the org wide address is available whenever the users want to send any email message.

 

Does anyone know how to use the org wide address in a trigger without providing access to the user’s profile? Any other solution like running the code always under another user (i.e. system admin)?

 

Thanks in advance!