function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mike SummittMike Summitt 

OrgWideEmailAddress permissions.

We're building a package which, among other things, sends emails.  We want to use a specific OrgWideEmailAddress as the sender of the email if, and only if, the currently logged on user's profile allows him/her access to that OrgWideEmailAddress, otherwise fall back and use the user's email address as the From.

We've encountered 2 problems.

In the administration menu, you can set an OrgWideEmailAddress to allow all profiles, or only certain profiles.  But if you select 2 profiles out of the list, or all of them but one, and save, it pretends to save your input but the list of OrgWideEmailAddress object will show "No Access" for that OrgWideEmailAddress.  Only if you select a single profile and save will the list show that the selected profile now has access.

In the code, the statement "SELECT Id, DisplayName, Address FROM OrgWideEmailAddress" returns all records, whether the currently logged on user's profile is allowed to use them or not.  There is no field, array, or related record that can be queried to determine whether an OrgWideEmailAddress is usable by the current user's profile.  If you attempt to send an email using try/catch, no exception is generated, but the email is not sent, and there's no mechanism to determine whether the email was refused due to non-permitted use of orgWideEmailAddress.

Does anyone have a strategy for getting around this problem?

UC InnovationUC Innovation
Hi Mike,

Which field of the OrgWideEmailAddress shows "No Access"? I've been looking at the SOAP API documentation here:

And the only fields are address, isAllowProfiles, and displayname. 

It looks like that query only returns whether the OrgWideEmailAddress uses all profiles or some profiles. It doens't give you a list of profiles that has access to it.
Mike SummittMike Summitt

UC, thanks for replying.  The "No Access" appears in the UI when looking at the list of organization-wide email addresses, after attempting to select multiple profiles to have access to a specific address.  And you're correct, the query returns all records whether the current user is allowed to use them or not, and there doesn't seem to be any way to tell programmatically if the current user can use them.

UC InnovationUC Innovation
Hi Mike,

That's strange... It shows the correct lis of profiles for me in the UI. Here's a screenshot:

User-added image

So you're seeing the "No Access" under the "Allowed Profiles" field?
Mike SummittMike Summitt

Yeah I even tried including System Administrator and I still got No Access, and if I go back to edit it, no profiles are selected in the list.  This doesn't follow their usual UI pattern in cases like this, with the 2 lists and the left and right buttons.

I'm on winter 17 in a partial copy sandbox.  What release are you on and what kind of environment?

UC InnovationUC Innovation
I'm running summer 16 in a developer org. 
Mike SummittMike Summitt

I wonder if this could be a new bug introduced in the winter 17 release?

Unfortunately, even if the UI worked correctly, and the database stored the profile permissions correctly, there's still no way for me to determine from code whether the logged in user can use a particular OWEA or not.

Jeff KranzJeff Kranz
I've been scouring the data model high and low for an object that stores which Profiles have access to which OrgWideEmailAddress records with no luck! Aghh, if anyone out there has any clues, lets not let this thread die.
Robert NordmanRobert Nordman
Any solutions in the last 4 years?  Trying to solve the same requirement.