• Gary W
  • NEWBIE
  • 15 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 9
    Questions
  • 17
    Replies
I'm building a Lightning web component to be used as a flow screen component. In the LWC, I allow the border color of the component to be customised using a custom property. To set the color of the element, I'm using variables in my CSS file, and then updating them to the value of the color property in my LWC .js code. I was originally setting CSS variables like this:
document.body.style.setProperty('--MyFSC-borderColor', this.borderColor);
However, this affected all instances of the flow screen component on a screen.

I found a suggestion (https://forcepanda.wordpress.com/2021/07/27/how-to-dynamically-set-custom-css-properties-in-lwc/comment-page-1/#comment-5025) to use the following code instead, which scopes the function to only the to the individual component:
this.template.host.style.setProperty('--MyFSC-borderColor', this.borderColor);
This worked perfectly, until i added a section component to my flow screen, after which I started getting the error:

Something went wrong with the "MyFSC" screen component on the "MyFlow" flow. Contact your Salesforce admin about this error. Cannot read properties of undefined (reading 'setProperty')

Removing the section component from the screen resolves the error, however I would like to be able to scope my CSS variables to individual FSC instances, while also using sections. How can this be done?
  • November 18, 2022
  • Like
  • 0
I have a custom object called Escalations related to my Cases. If I create a new escalation via a custom 'create a record' action on my case, it creates a feed item which looks like this:
User-added image

If I create the escalation using a flow, using the create records element, the feed item is not automatically created. 

I have tried manually creating the feed item in the same flow which creates the escalation. I'm creating new record on the feedItem object. The values I'm using are:
  • ParentId = Escalation ID
  • Feed Item Type = CreateRecordEvent
  • Visibility = AllUsers
When I create the feed item record, I cannot see it on the case, which kind of makes sense, since I have not directly referenced the case in the feed item.

Can anyone point me in the right direction on how to create a feed item which shows up on the case feed like in the screenshot above?
The new email-to-case threading behaviour is described in this knowledge article (https://help.salesforce.com/articleView?id=000355168&type=1&mode=1). I've reviewed this, but cannot understand how to reference a case record on an outbound email, when there has not been any previous email messages recorded on the case yet.

Previously, we could include the thread Ref Id from the case in an outbound email and have the replies route into the case via email-to-case.

Now that this is being deprecated, using the new method, how do we ensure that replies will be threaded to a case, which has no existing email messages, when sending an outbound email (though an apex action)?
  • February 25, 2021
  • Like
  • 0
My flow is occasionally encountering an issue where the Lead's RecordTypeId is null, when it should have a real record type ID value.

I have three custom record types set up on the Lead object, so as far as I'm aware, the record type should never be null.

My flow starts off like this: 
User-added image
The ID of the lead to get is provided as an input variable.

Occasionally encounter an issue like this where the 'Get Record Type' element encounters a null:
 
How the Interview Started
User started the flow interview.
API Version for Running the Flow: 49
Some of this flow's variables were set when the interview started.
VarLeadID = 00Q3j00001PoMiyEAF

GET RECORDS: Get_Lead
Find all Lead records where:
Id Equals {!VarLeadID} (00Q3j00001PoMiyEAF)
Store the values of these currently referenced fields in Get_Lead: Status, ConvertedAccountId, Sourced_by_Partner__c, Partner__c, Sent_to_Partner__c, Region__c, ConvertedContactId, Referral_Email__c, OwnerId, RecordTypeId, Trial_Start_Date__c, Country, Id, Salesperson_Referral_Link_Used__c, ConvertedOpportunityId, Referral_Code__c
Because Get_Lead is passed to an action, subflow, or Lightning component, store the values of all Lead fields that the running user has access to.
Result
Successfully found records.

GET RECORDS: Get_Record_Type
Find all RecordType records where:
Id Equals {!Get_Lead.RecordTypeId} (null)
Store the values of these fields in Get_Record_Type: Id, DeveloperName
Result
Failed to find records.

Looking at the lead record, it has a valid record type ID. Why is it null when the flow executes?
  • February 11, 2021
  • Like
  • 0
The error "INACTIVE_OWNER_OR_USER, Record owner cannot be an inactive user" is being thrown in my flow, when it tries to create a new opportunity using an inactive users ID as the ownerId, via an apex action.

The desired outcome is to allow the inactive user to become the owner of the opportunity record. I followed the below article to enable setting "Update Records with Inactive Owners".
https://help.salesforce.com/articleView?id=000334139&type=1&mode=1

With this setting enabled, I created a permission set and included "Update Records with Inactive Owners" in it, then assigned it to my user. I am now able to manually insert an opportunity with the ownerId set to an inactive user, without error.

In my flow, I'm using a custom apex action to convert a lead to an account/contact/opportunity. When debugging the flow and using the inactive user, it fails with the error "INACTIVE_OWNER_OR_USER, Record owner cannot be an inactive user".

I don't understand why I'm able to insert an opportunity with an inactive user as the opportunity owner manually, but not though an apex action.
  • December 07, 2020
  • Like
  • 0
My flow is pretty simple, it simply returns the account record found for a given account number, along with the record type name.

The whole flow looks like this:
User-added image

The Get Account element is below. This is the element that is erroring.
User-added image

When I debug the flow, the debug output looks like this for the Get_Account step:
 
Fast Lookup: Get_Account
Find all Account records where
AccountNumber Equals {!VarAccountNumber} (A00012345)
Sort records by: CreatedDate (Ascending)
Store the values of these currently referenced fields in Get_Account: RecordTypeId, Id
Because Get_Account is passed to an action, subflow, or Lightning component, store the values of all Account fields that the running user has access to.

Result
Failed to find records.

Error Occurred:
This error occurred when the flow tried to look up records: An unexpected error occurred. Please include this ErrorId if you contact support: 908556789-5354 (-548403183). You can look up ExceptionCode values in the SOAP API Developer Guide.

When I look in the developer console logs, I can see the following error occuring:
System.QueryException: Non-selective query against large object type (more than 200000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)

I found this knowledge article (https://help.salesforce.com/articleView?id=000323572&type=1&mode=1) which gives some further detail on the error. It suggests that queries should return less 10% or less of the data. My query would only return 1 record. I currently have a total of ~364k account records. This shouldn't be a problem.

I've tried writing a SOQL query that would be equivalent of what's being queried in the flow. It looks like this:
SELECT [all fields] FROM Account WHERE AccountNumber = 'A00012345'
Replacing [all fields] with all my account object fields, and running the query, it returns 1 row without any errors.

According to all the salesforce documentation I could find, this shouldn't be a problem, yet for some reason the flow encounters this issue. 

I've tried adding further conditions to the Get_Account element, to try and make the query more selective:
User-added imageThis did not resolve the issue and the same error occurs.

The other suggestion in the Salesforce documentation is to index the field. Since Account Number is a standard field, I can't make it an external ID, so I'll need to contact support for this.

Can anyone explain why this error is affecting me, when all the documentation, and test queries I run suggest that it shouldn't be occurring?
  • November 20, 2020
  • Like
  • 0
I want to use the value of the account custom text field named 'Id__c', in a custom link on the account object. I want the custom link to go to two different pages depending on if there's a value in the 'Id__c' field or not.

My formula looks like this:
{!IF(
    ISBLANK( Account.Id__c ),
    URLFOR("http://isBlank.com", null),
    URLFOR("http://isNotBlank.com/" & Account.Id__c, null)
)}


/* I'm using the URLFOR() function in order for the URL returned by the function to be properly encoded */
If the 'Id__c' field is blank, I would expect the link to go to http://isBlank.com, however upon testing:
  • If the 'Account.Id__c' field is blank, the link goes to http://isNotBlank.com/001m000001Fc4xR.
  • If the 'Account.Id__c' field has the value "12345", the link goes to http://isNotBlank.com/12345.

As you can see, the ISBLANK() function is always returning false, since if the 'Account.Id__c' field value is actually blank, the function appears to be evaluating the 'Account.Id' value instead, which can never be blank. Either way, it's always evaluating a non-blank value.

I simplified the formula for testing, to just the following:
http://example.com/{!Account.Id__c}
  • If the 'Account.Id__c' field is blank, the link goes to http://example.com/001m000001Fc4xR.
  • If the 'Account.Id__c' field has the value "12345" the link goes to http://example.com/12345.
I believe this is a bug. How can I workaround this issue to effectively test for a blank value in my Id__c field?

Here's some screenshots showing the issue:
User-added image
User-added image
User-added image
I verified that the field is actually blank using Salesforce Inspector.
User-added image
  • September 29, 2020
  • Like
  • 0
The phone utility can be popped out by default, which causes problems with our CTI adapter. How can we configure this to disable the popout control?

I've looked over the following docs on how this could be disabled: https://help.salesforce.com/articleView?id=sforce_api_console_lightning_utility_popout.htm&type=5
I've also found the following idea which is marked as delivered: https://trailblazer.salesforce.com/ideaView?id=0873A000000U06TQAS

Our Salesforce call center is configured with our providers CTI adapter referenced in the 'CTI Adapter URL' field. I'm not able to find any visualforce pages or lighting web components to customise this popuout behaviour on.

Can someone please point me in the right direction?
  • September 15, 2020
  • Like
  • 0
We are in the process of creating around 2,000 knowledge articles for one of our new communities. We are creating the articles using the REST API.

When creating knowledge articles manually in the console, the rich text editor allows for inline images to be uploaded and displayed in the article bodies. Is there an API endpoint, or a suggested method we could use for programmatically uploading images to display in articles bodies?
  • March 12, 2020
  • Like
  • 0
Hi everyone.  I hope you can help with an issue i'm having around sending emails from apex.

What's the setup?
I have a web-to-case form setup, which is working fine in all aspects. I have a trigger/class that will verify the information and send an email back if details could not be found/matched in salesforce.  Valid cases come through just fine, having the System user as the CreatedBy.  Invalid or unmatched details have a process in place where the case is deleted and an email sent out to the address provided on the form asking the person to call instead.  The sender of this email is set from the Oeg-Wide Email Address list.  Here's an extract of the code handling this:
EmailTemplate emailTemplate = [SELECT Id, Body, HtmlValue FROM EmailTemplate WHERE DeveloperName = 'Case_W2C_Details_Mismatch_Template'];
            System.debug('Email template ID = '+emailTemplate.Id);
            OrgWideEmailAddress owea = [SELECT Id, Address, DisplayName FROM OrgWideEmailAddress WHERE Address = 'No-Reply@company.co.uk'];
            System.debug('Email address Id for sender = '+owea.Id);
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            if ( owea != null) {email.setOrgWideEmailAddressId(owea.Id);}
            email.setToAddresses(emailAddresses);
            email.setSaveAsActivity(false);
            email.setSubject('Online Enquiry');
            email.setHtmlBody(emailTemplate.HtmlValue);
            email.setTemplateId(emailTemplate.Id);

            if(EmailDeliverabilityEnabled){
                Messaging.SendEmailResult [] res = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
                System.debug('Send email result' + res);
            }
            else {
                System.debug('WebToCaseService_Error: Email Deliverability is not enabled');
            }

So what's the issue then?
Every part of the process is working fine except the latter, where details are unmatched.  No email is going out to the address provided and in the logs i get this error:

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

What have i already tried?
1. I went to the no-reply email address in the Org-Wide Email Adresses and edited it to "Allow All Profiles to Use this From Address"

User-added image
This does work, however it allows users to be able to select this email when sending emssages via salesforce - whcih we don't want. 

2. If i "Allow only selected profiles.." and include System Administrator the above error is still faced. 

3. If i "Allow only selected profiles.." and manually select all listed profiles - i still get the same error.

4. I then set up another default no-reply address as a "Special Purpose Org-Wide Email Address" and changing the code to use this instead.  This also worked but is an address inaccessible to selected profiles, so doesn't resolve the issue without creating another.

My Questions then
Why would System user not be allowed access to Org-Wide Emails?  Is there a way around this without setting up a second no-reply address specifically for this purpose?

Many thanks for reading through this.
Aamir
  • July 26, 2021
  • Like
  • 1
I have a custom object called Escalations related to my Cases. If I create a new escalation via a custom 'create a record' action on my case, it creates a feed item which looks like this:
User-added image

If I create the escalation using a flow, using the create records element, the feed item is not automatically created. 

I have tried manually creating the feed item in the same flow which creates the escalation. I'm creating new record on the feedItem object. The values I'm using are:
  • ParentId = Escalation ID
  • Feed Item Type = CreateRecordEvent
  • Visibility = AllUsers
When I create the feed item record, I cannot see it on the case, which kind of makes sense, since I have not directly referenced the case in the feed item.

Can anyone point me in the right direction on how to create a feed item which shows up on the case feed like in the screenshot above?

I have created formula field in which i used Account__r.Id but it is showing blank. 

 

My flow is occasionally encountering an issue where the Lead's RecordTypeId is null, when it should have a real record type ID value.

I have three custom record types set up on the Lead object, so as far as I'm aware, the record type should never be null.

My flow starts off like this: 
User-added image
The ID of the lead to get is provided as an input variable.

Occasionally encounter an issue like this where the 'Get Record Type' element encounters a null:
 
How the Interview Started
User started the flow interview.
API Version for Running the Flow: 49
Some of this flow's variables were set when the interview started.
VarLeadID = 00Q3j00001PoMiyEAF

GET RECORDS: Get_Lead
Find all Lead records where:
Id Equals {!VarLeadID} (00Q3j00001PoMiyEAF)
Store the values of these currently referenced fields in Get_Lead: Status, ConvertedAccountId, Sourced_by_Partner__c, Partner__c, Sent_to_Partner__c, Region__c, ConvertedContactId, Referral_Email__c, OwnerId, RecordTypeId, Trial_Start_Date__c, Country, Id, Salesperson_Referral_Link_Used__c, ConvertedOpportunityId, Referral_Code__c
Because Get_Lead is passed to an action, subflow, or Lightning component, store the values of all Lead fields that the running user has access to.
Result
Successfully found records.

GET RECORDS: Get_Record_Type
Find all RecordType records where:
Id Equals {!Get_Lead.RecordTypeId} (null)
Store the values of these fields in Get_Record_Type: Id, DeveloperName
Result
Failed to find records.

Looking at the lead record, it has a valid record type ID. Why is it null when the flow executes?
  • February 11, 2021
  • Like
  • 0
The error "INACTIVE_OWNER_OR_USER, Record owner cannot be an inactive user" is being thrown in my flow, when it tries to create a new opportunity using an inactive users ID as the ownerId, via an apex action.

The desired outcome is to allow the inactive user to become the owner of the opportunity record. I followed the below article to enable setting "Update Records with Inactive Owners".
https://help.salesforce.com/articleView?id=000334139&type=1&mode=1

With this setting enabled, I created a permission set and included "Update Records with Inactive Owners" in it, then assigned it to my user. I am now able to manually insert an opportunity with the ownerId set to an inactive user, without error.

In my flow, I'm using a custom apex action to convert a lead to an account/contact/opportunity. When debugging the flow and using the inactive user, it fails with the error "INACTIVE_OWNER_OR_USER, Record owner cannot be an inactive user".

I don't understand why I'm able to insert an opportunity with an inactive user as the opportunity owner manually, but not though an apex action.
  • December 07, 2020
  • Like
  • 0
My flow is pretty simple, it simply returns the account record found for a given account number, along with the record type name.

The whole flow looks like this:
User-added image

The Get Account element is below. This is the element that is erroring.
User-added image

When I debug the flow, the debug output looks like this for the Get_Account step:
 
Fast Lookup: Get_Account
Find all Account records where
AccountNumber Equals {!VarAccountNumber} (A00012345)
Sort records by: CreatedDate (Ascending)
Store the values of these currently referenced fields in Get_Account: RecordTypeId, Id
Because Get_Account is passed to an action, subflow, or Lightning component, store the values of all Account fields that the running user has access to.

Result
Failed to find records.

Error Occurred:
This error occurred when the flow tried to look up records: An unexpected error occurred. Please include this ErrorId if you contact support: 908556789-5354 (-548403183). You can look up ExceptionCode values in the SOAP API Developer Guide.

When I look in the developer console logs, I can see the following error occuring:
System.QueryException: Non-selective query against large object type (more than 200000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)

I found this knowledge article (https://help.salesforce.com/articleView?id=000323572&type=1&mode=1) which gives some further detail on the error. It suggests that queries should return less 10% or less of the data. My query would only return 1 record. I currently have a total of ~364k account records. This shouldn't be a problem.

I've tried writing a SOQL query that would be equivalent of what's being queried in the flow. It looks like this:
SELECT [all fields] FROM Account WHERE AccountNumber = 'A00012345'
Replacing [all fields] with all my account object fields, and running the query, it returns 1 row without any errors.

According to all the salesforce documentation I could find, this shouldn't be a problem, yet for some reason the flow encounters this issue. 

I've tried adding further conditions to the Get_Account element, to try and make the query more selective:
User-added imageThis did not resolve the issue and the same error occurs.

The other suggestion in the Salesforce documentation is to index the field. Since Account Number is a standard field, I can't make it an external ID, so I'll need to contact support for this.

Can anyone explain why this error is affecting me, when all the documentation, and test queries I run suggest that it shouldn't be occurring?
  • November 20, 2020
  • Like
  • 0
The phone utility can be popped out by default, which causes problems with our CTI adapter. How can we configure this to disable the popout control?

I've looked over the following docs on how this could be disabled: https://help.salesforce.com/articleView?id=sforce_api_console_lightning_utility_popout.htm&type=5
I've also found the following idea which is marked as delivered: https://trailblazer.salesforce.com/ideaView?id=0873A000000U06TQAS

Our Salesforce call center is configured with our providers CTI adapter referenced in the 'CTI Adapter URL' field. I'm not able to find any visualforce pages or lighting web components to customise this popuout behaviour on.

Can someone please point me in the right direction?
  • September 15, 2020
  • Like
  • 0
We are in the process of creating around 2,000 knowledge articles for one of our new communities. We are creating the articles using the REST API.

When creating knowledge articles manually in the console, the rich text editor allows for inline images to be uploaded and displayed in the article bodies. Is there an API endpoint, or a suggested method we could use for programmatically uploading images to display in articles bodies?
  • March 12, 2020
  • Like
  • 0
I’m attempting to migrate metadata from one org to another using a package.  But my deployment keeps failing with “Error  test/applications/Underwriting.app  Underwriting  invalid cross reference id”

Originally I was all three .app files in my metadata package were failing.  Then I did something (IDK what – I tried a bunch of stuff) that got two of the .app files to deploy and only one is failing now.

Looking at what changed in the .app files that failed but now deploy without error, I notice they no longer contain references to many standard profiles.  They only reference custom profiles and the Admin profile.  No other standard profiles besides Admin.

Also, if I look at the .app files that continues to cause problems, I see that it contains references to many if not all of the standard profiles.  As a result, I suspect it is the inclusion of these standard profiles that is causing problems.

I thought the fix would be easy: go to Setup > App Manager > App Settings > User Profiles, move the standard profiles from the Selected Profiles column to the Available profiles column and then update the package.

The problem is that it does not seem that changes I make to App Manager > App Settings > User Profiles are reflected in the .app metadata files in my package.

Removing standard profiles from the app with the .app file producing the error does not remove them from the .app metadata file.  Similarly, adding standard profiles to the apps whose .app files do not contain standard profiles does not add the selected standard profiles to these .app files.

This has left me perplexed.  Is the issue the standard profiles in the .app file?  If not App Manager > App Settings > User Profiles, how do I control which profiles appear in my .app files? 

Note: I’ve searched for similar errors / possible solutions.  The first link below sounds most similar but it’s marked as a “fixed” known issue as of a year ago so I don’t think that’s the issue.  The second link says there’s an invalid record ID in my code.  But the error messages I get identify the files producing the error and I’m 100% positive they do not contain any record (or other IDs).

https://success.salesforce.com/issues_view?id=a1p3A000000mCIdQAM&title=invalid-cross-reference-id-deploying-custom-app-with-profileactionoverrides-referencing-new-profiles-in-same-deployment (https://success.salesforce.com/issues_view?id=a1p3A000000mCIdQAM&title=invalid-cross-reference-id-deploying-custom-app-with-profileactionoverrides-referencing-new-profiles-in-same-deployment" style="color:blue; text-decoration:underline)

https://developer.salesforce.com/forums/?id=906F0000000BIhXIAW (https://developer.salesforce.com/forums/?id=906F0000000BIhXIAW" style="color:blue; text-decoration:underline)
 
I have a lightning component that opens from the Utility bar called OutOfOffice, the customer would like the window to auto close after pressing the Save button. Does anyone know how this can be accomplished? See the image below for visual.
User-added image
I am trying to add more than 3 levels of picklists in a screenflow the screenflow is limited to 3, i tried to pass value from the third picklist to a new screenflow with another dependent picklist component but this does not work. 

Example:
Picklist 1 has values A, B, C, D 
Picklist 2 has values E, F,G, H, I
PIcklist 3 has values J,K,L,M
PIcklist 4 has values N, O, P Q
PIcklist 5has values R, S, T

For picklist 1
If A is chosen  show values E, F
If B is chosen show G, H

For picklist 2 
If E is chosen show values J, K 

For picklist 3 
If J is chosen show value N, P

For picklist 4  (screenflow does not allow to have this 4th picklist)
If P is chosen show R, T

Let's say for picklist 3 i chose P, i want to continue this picklist sequence to see the other values R and T, but since the screen flow only allows 3 picklistsi tried to save this value that was chosen and pass it to a new screen component to continue the picklist sequence.

How can i do this?
Challenge Not yet complete... here's what's wrong:  There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: EPCRKTQS
I'm using Visual Flow and have a multi-select checkbox input that puts the checked results into a semi-colon delimited variable (populated with Contact Ids).  Now I need to use this variable to build an SObject Collection so I can fast update the selected records.

How could I go about this?

Hi all,

 

I am trying to make a field which displays this:

 

48 x 180 (8,640)

 

But I'm getting this (no separators):

 

48 x 180 (8640)

 

Here's the code I'm using:

 

TEXT(Lot__r.Unit_Count__c) & " x " & TEXT(Lot__r.kg_unit__c) &" (" & TEXT((Lot__r.Unit_Count__c * Lot__r.kg_unit__c)) & ")"

 

Is there a simple way to insert comma separators in TEXT numbers - or perhaps a better way to do this? I am stumped and think the only way must be to write some combination of RIGHT and TRIM statements - or something else? This must have come up before, right?

 

It's easy in APEX:

 

<apex:outputText value="{0, number, ###,###,###,###}"><apex:param value="{!Quote.Total_Price__c}"/></apex:outputText>

 

...but does not work in formula fields.

 

What am I missing? Thanks much for any help.

 

Alex

 

 

 

Hi everyone.  I hope you can help with an issue i'm having around sending emails from apex.

What's the setup?
I have a web-to-case form setup, which is working fine in all aspects. I have a trigger/class that will verify the information and send an email back if details could not be found/matched in salesforce.  Valid cases come through just fine, having the System user as the CreatedBy.  Invalid or unmatched details have a process in place where the case is deleted and an email sent out to the address provided on the form asking the person to call instead.  The sender of this email is set from the Oeg-Wide Email Address list.  Here's an extract of the code handling this:
EmailTemplate emailTemplate = [SELECT Id, Body, HtmlValue FROM EmailTemplate WHERE DeveloperName = 'Case_W2C_Details_Mismatch_Template'];
            System.debug('Email template ID = '+emailTemplate.Id);
            OrgWideEmailAddress owea = [SELECT Id, Address, DisplayName FROM OrgWideEmailAddress WHERE Address = 'No-Reply@company.co.uk'];
            System.debug('Email address Id for sender = '+owea.Id);
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            if ( owea != null) {email.setOrgWideEmailAddressId(owea.Id);}
            email.setToAddresses(emailAddresses);
            email.setSaveAsActivity(false);
            email.setSubject('Online Enquiry');
            email.setHtmlBody(emailTemplate.HtmlValue);
            email.setTemplateId(emailTemplate.Id);

            if(EmailDeliverabilityEnabled){
                Messaging.SendEmailResult [] res = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
                System.debug('Send email result' + res);
            }
            else {
                System.debug('WebToCaseService_Error: Email Deliverability is not enabled');
            }

So what's the issue then?
Every part of the process is working fine except the latter, where details are unmatched.  No email is going out to the address provided and in the logs i get this error:

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

What have i already tried?
1. I went to the no-reply email address in the Org-Wide Email Adresses and edited it to "Allow All Profiles to Use this From Address"

User-added image
This does work, however it allows users to be able to select this email when sending emssages via salesforce - whcih we don't want. 

2. If i "Allow only selected profiles.." and include System Administrator the above error is still faced. 

3. If i "Allow only selected profiles.." and manually select all listed profiles - i still get the same error.

4. I then set up another default no-reply address as a "Special Purpose Org-Wide Email Address" and changing the code to use this instead.  This also worked but is an address inaccessible to selected profiles, so doesn't resolve the issue without creating another.

My Questions then
Why would System user not be allowed access to Org-Wide Emails?  Is there a way around this without setting up a second no-reply address specifically for this purpose?

Many thanks for reading through this.
Aamir
  • July 26, 2021
  • Like
  • 1