• Chad.Pfrommer
  • NEWBIE
  • 35 Points
  • Member since 2015

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 20
    Replies
In most of the emails I recieve, the subject contains a 6 digit "job number", which designates which assignment the email is about. Many of these emails come from the same email address, so the job number is the only way I can associate an incoming email with a specific opportunity. 

Is there any way to parse each incoming email subject to look for a 6 digit code?
Anybody know why adding sorting to a lightning-datatable causes cell highlighting to behave so erratically? Like, it stops handling the addition/removal of the slds-has-focus class to cells appropriately and you end up with several "highlighted" cells at the same time.

You can see it in the SF example here (https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/example) (choose "Datatable with Sortable Columns").  If you start alternating between clicking around various cells and sorting by the Age column you can see what happens.
I'm seeing some weird behavior while trying to deserialize json containing some Accounts with child objects.  Example code:
String accountsJson = 
'[' +
'    {' +
'        "attributes": {' +
'            "type": "Account",' +
'            "url": "/services/data/v32.0/sobjects/Account/a0YG0000005Jn5uMAC"' +
'        },' +
'        "Name": "Fred",' +
'        "Id": "a0YG0000005Jn5uMAC",' +
'        "abc__r": {' +
'            "totalSize": 1,' +
'            "done": true,' +
'            "records": [' +
'                {' +
'                    "attributes": {' +
'                        "type": "abc__c ",' +
'                        "url": "/services/data/v32.0/sobjects/abc__c /a0ZG0000006JGPAMA4"' +
'                    },' +
'                    "Name": "Bob",' +
'                    "Id": "a0ZG0000006JGPAMA4",' +
'                    "Account__c": "a0YG0000005Jn5uMAC"' +
'                }' +
'            ]' +
'        }' +
    '}' +
']';

List<Account> accts = (List<Account>) JSON.deserialize(accountsJson, List<Account>.class);

The json shows a list of Accounts with only 1 Account, along with with a custom child object, abc__c (master-detail relationship).  Now, the above code is working fine for the abc__c object, however I have another custom object in my org with the exact same relationship to Account, lets call it xyz__c.  If I change the above json to use xyz__c child objects (via s/abc/xyz/g), then I get the following error during the deserialization:

"System.JSONException: Cannot deserialize instance of <unknown> from FIELD_NAME value totalSize or request may be missing a required field"

Incidentally - I have also reproduced this problem by inserting and querying for records and then serializing those results and then immediately deserializing the results, like so:
 
Savepoint sp = Database.setSavepoint();
Account a = new Account(Name = 'test acct');
insert a;
abc__c abc = new abc__c (
	Account__c = a.Id
);
insert abc;

List<Account> accts = [select Id,
                    (select Id
                        from abc__r)
                from Account where Id = :a.Id];
String acctStr = JSON.serialize(accts[0]);
JSON.deserialize(acctStr, Account.class);
Database.rollback(sp);
The above code works fine for abc__c, but not xyz__c.


Background:
I was writing some unit tests and I needed to mock some query results for a list of Accounts with child data as well.  Since the relationship fields aren't writable (like Account.Opportunities, for example), the way to do that is through JSON serialization/desaerialization.  I've done this in the past, and I went about it the same way I have before and started seeing this error.  It's only this particular custom object where I'm getting this problem.  I went ahead and switched over to the ApexMocks method for doing this as well (fflib_ApexMocksUtils.makeRelationship) and I ran into the same error there.
I'm running into a curious situation where I'm getting an "ENTITY_IS_DELETED" error when trying to update a record that was previously inserted within the same transaction.  The error is occurring within an After Insert trigger on the CampaignMember object where I'm trying to update the new Lead.

This isn't the original code that was giving me the issue, however while troubleshooting I was able to cause the same error to happen with the following update:
Lead l = [SELECT Id, LastName FROM Lead WHERE Id = :leadId];  // <== gets the previously inserted lead
if (l.LastName == 'Sinatra') {  // temporary for testing
    l.FirstName = 'Ted';
    update l;  // <=== ENTITY_IS_DELETED, Cannot save already-deleted object: id = 00Qm0000008Sn20: []
}
Full error message:
15:59:20:995 EXCEPTION_THROWN [39]|System.DmlException: Update failed. First exception on row 0 with id 00Qm0000008Sn20EAC; first error: ENTITY_IS_DELETED, Cannot save already-deleted object: id = 00Qm0000008Sn20: []

I've also used the Database.update method and printed out the SaveResult:
Database.SaveResult[getErrors=(Database.Error[getFields=();getMessage=Cannot save already-deleted object: id = 00Qm0000008Sn8m;getStatusCode=ENTITY_IS_DELETED;]);getId=null;isSuccess=false;]

Like I mentioned, the Lead being updated was previously inserted within the same transaction.  I don't understand why I'd be able to query it and have an attempt to update it result in an ENTITY_IS_DELETED error.

I've searched around and haven't found an answer to this issue.  The only thing I can think of is that it's not the Lead being updated that's causing the error, but potentially something else that's being updated as a result of the lead update and that error is hidden somewhere.
Salesforce provides date literals you can use in your SOQL queries.  Here's their documentation - see page 20:

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_create.htm

When I run:
SELECT Id FROM Opportunity WHERE CloseDate = THIS_FISCAL_YEAR
through Dev console in my prod org, I get an invalid date error.  When I run queries in the same org using other date literals, like the example queries from the docs, they work fine.  That query executed in a partial sandbox doesn't work either.  That query executed in my own developer org works fine.

Anyone else ever experienced this?

There is an apex class in production that is using that query - and it's currently running fine.  Unfortunately, when we try to push changesets to prod and run all our unit tests, we get compilation errors on that class.  Our current workaround is to select specific unit tests to run when deploying to prod, however this solution is far less than ideal, and won't help if we need to make changes to that class.
I've searched around and read through the Instance Refresh Maintenance Knowledge Base article and I can't find an answer to this question.

I have an org on na23, which while soon go through a refresh and end up on na53.  I currently have a few custom email services within that org, both of which have email addresses with domains that end in "na23.apex.salesforce.com".  The domains for these email addresses are system generated - I can't change them.

When na23 gets refreshed and becomes na53, will the SFDC platform route emails sent to the current "na23.apex.salesforce.com" email addresses to my org where it resides on the new hardware?  Or do I need to coordinate with every 3rd party using those email addresses and have them switch to a new email address after the refresh - and if so, can I find out what the new email address will be ahead of time?  Will it be the same except for s/na23/na53/?
I've only seen 1 other post about this issue and the resolution there isn't working for me.

I'm trying to mass move around 300 old reports to a specific folder using the Force.com IDE.  These are the steps I'm taking:

1) create a new Force.com project in Eclipse, including the metadata for reports
2) locally move the *.report metadata files for the reports I'd like to move to the folder where I want them
3) highlight the "reports" folder in the Package Explorer and choose "Force.com -> Save to Server"

The result is that a large portion of the reports are moved, however any report who's metadata xml includes the <currency> element isn't moved, and the error message for each of them is "Save error: currency: Unsupported currency: USD" (or EUR, or GBP - whatever currency is specified).

Anybody have any ideas on this?
The following code works fine:
List<Datetime> dtList = new List<Datetime>();
List<Object> oList = (List<Object>) dtList;

The following code, however, does not compile:
Set<Datetime> dtSet = new Set<Datetime>();
Set<Object> oSet = (Set<Object>) dtSet;

It results in a "Incompatible types since an instance of Set<Datetime> is never an instance of Set<Object>" compilation error.

Same thing here:
 
public class TestA {
}
public class TestB extends TestA {
}

List<TestB> tbList = new List<TestB>();
List<TestA> taList = (List<TestA>) tbList; // <--- compiles fine

Set<TestB> tbSet = new Set<TestB>();
Set<TestA> taSet = (Set<TestA>) tbSet;  // <--- doesn't compile
 
And here:
 
List<Account> aList = new List<Account>();
List<SObject> soList = (List<SObject>) aList; // <--- works fine

Set<Account> aSet = new Set<Account>();
Set<SObject> soSet = (Set<SObject>) aSet; // <--- compilation error
 
Am I missing something obvious?  If not, is there a reason you can't cast Sets like this?
The following code works fine:
List<Datetime> dtList = new List<Datetime>();
List<Object> oList = (List<Object>) dtList;

The following code, however, does not compile:
Set<Datetime> dtSet = new Set<Datetime>();
Set<Object> oSet = (Set<Object>) dtSet;

It results in a "Incompatible types since an instance of Set<Datetime> is never an instance of Set<Object>" compilation error.

Same thing here:
 
public class TestA {
}
public class TestB extends TestA {
}

List<TestB> tbList = new List<TestB>();
List<TestA> taList = (List<TestA>) tbList; // <--- compiles fine

Set<TestB> tbSet = new Set<TestB>();
Set<TestA> taSet = (Set<TestA>) tbSet;  // <--- doesn't compile
 
And here:
 
List<Account> aList = new List<Account>();
List<SObject> soList = (List<SObject>) aList; // <--- works fine

Set<Account> aSet = new Set<Account>();
Set<SObject> soSet = (Set<SObject>) aSet; // <--- compilation error
 
Am I missing something obvious?  If not, is there a reason you can't cast Sets like this?
I'm seeing some weird behavior while trying to deserialize json containing some Accounts with child objects.  Example code:
String accountsJson = 
'[' +
'    {' +
'        "attributes": {' +
'            "type": "Account",' +
'            "url": "/services/data/v32.0/sobjects/Account/a0YG0000005Jn5uMAC"' +
'        },' +
'        "Name": "Fred",' +
'        "Id": "a0YG0000005Jn5uMAC",' +
'        "abc__r": {' +
'            "totalSize": 1,' +
'            "done": true,' +
'            "records": [' +
'                {' +
'                    "attributes": {' +
'                        "type": "abc__c ",' +
'                        "url": "/services/data/v32.0/sobjects/abc__c /a0ZG0000006JGPAMA4"' +
'                    },' +
'                    "Name": "Bob",' +
'                    "Id": "a0ZG0000006JGPAMA4",' +
'                    "Account__c": "a0YG0000005Jn5uMAC"' +
'                }' +
'            ]' +
'        }' +
    '}' +
']';

List<Account> accts = (List<Account>) JSON.deserialize(accountsJson, List<Account>.class);

The json shows a list of Accounts with only 1 Account, along with with a custom child object, abc__c (master-detail relationship).  Now, the above code is working fine for the abc__c object, however I have another custom object in my org with the exact same relationship to Account, lets call it xyz__c.  If I change the above json to use xyz__c child objects (via s/abc/xyz/g), then I get the following error during the deserialization:

"System.JSONException: Cannot deserialize instance of <unknown> from FIELD_NAME value totalSize or request may be missing a required field"

Incidentally - I have also reproduced this problem by inserting and querying for records and then serializing those results and then immediately deserializing the results, like so:
 
Savepoint sp = Database.setSavepoint();
Account a = new Account(Name = 'test acct');
insert a;
abc__c abc = new abc__c (
	Account__c = a.Id
);
insert abc;

List<Account> accts = [select Id,
                    (select Id
                        from abc__r)
                from Account where Id = :a.Id];
String acctStr = JSON.serialize(accts[0]);
JSON.deserialize(acctStr, Account.class);
Database.rollback(sp);
The above code works fine for abc__c, but not xyz__c.


Background:
I was writing some unit tests and I needed to mock some query results for a list of Accounts with child data as well.  Since the relationship fields aren't writable (like Account.Opportunities, for example), the way to do that is through JSON serialization/desaerialization.  I've done this in the past, and I went about it the same way I have before and started seeing this error.  It's only this particular custom object where I'm getting this problem.  I went ahead and switched over to the ApexMocks method for doing this as well (fflib_ApexMocksUtils.makeRelationship) and I ran into the same error there.
I'm running into a curious situation where I'm getting an "ENTITY_IS_DELETED" error when trying to update a record that was previously inserted within the same transaction.  The error is occurring within an After Insert trigger on the CampaignMember object where I'm trying to update the new Lead.

This isn't the original code that was giving me the issue, however while troubleshooting I was able to cause the same error to happen with the following update:
Lead l = [SELECT Id, LastName FROM Lead WHERE Id = :leadId];  // <== gets the previously inserted lead
if (l.LastName == 'Sinatra') {  // temporary for testing
    l.FirstName = 'Ted';
    update l;  // <=== ENTITY_IS_DELETED, Cannot save already-deleted object: id = 00Qm0000008Sn20: []
}
Full error message:
15:59:20:995 EXCEPTION_THROWN [39]|System.DmlException: Update failed. First exception on row 0 with id 00Qm0000008Sn20EAC; first error: ENTITY_IS_DELETED, Cannot save already-deleted object: id = 00Qm0000008Sn20: []

I've also used the Database.update method and printed out the SaveResult:
Database.SaveResult[getErrors=(Database.Error[getFields=();getMessage=Cannot save already-deleted object: id = 00Qm0000008Sn8m;getStatusCode=ENTITY_IS_DELETED;]);getId=null;isSuccess=false;]

Like I mentioned, the Lead being updated was previously inserted within the same transaction.  I don't understand why I'd be able to query it and have an attempt to update it result in an ENTITY_IS_DELETED error.

I've searched around and haven't found an answer to this issue.  The only thing I can think of is that it's not the Lead being updated that's causing the error, but potentially something else that's being updated as a result of the lead update and that error is hidden somewhere.
Hello,
I'm still learning Apex and am having issues this this particular trigger.  We want to automate the creation of a renewal opportunity when an opportunity is moved to Closed won.  

Requirements
1. Opportunity is Won
2. Create a Renewal Opportunity with a close date of +365 days
3. Clone the primary quotes under the original Opportunity and associate them to the renewal Opportunity
4. Clone the Lines under the Original primary quotes and assoicate them to the cloned "renewal" quotes

Here is my code so far.  The error I'm running into is the CPU time limit error, and was gatting the too many SOQL queries earlier.  Your help is greatly appreciated!  

trigger Renewals2 on Opportunity (before update) {
    
    List <SCMC__Customer_Quotation__c> finalCustomerQuotations = new list <SCMC__Customer_Quotation__c>();
    List <SCMC__Customer_Quotation_Line__c> finalCQLines = new list <SCMC__Customer_Quotation_Line__c>();
    Map <ID,Opportunity> OrgOpptoRenewOpp = new Map <ID,Opportunity>();
    Map <ID,SCMC__Customer_Quotation__c> OrgCQtoRenewCQ = new Map <ID,SCMC__Customer_Quotation__c>();
    List <Opportunity> renewalOpps = new list <Opportunity>();
    
    for(Opportunity O : trigger.new){
        if (O.StageName == 'Closed - Won'){
            //Create a renewal Opportunities            
            Opportunity newOpp   = new Opportunity();
            newOpp.name          = O.name+'_RENEWAL';
            newOpp.Stagename     = 'Decision - 60%';
            newOpp.CloseDate     = O.CloseDate + 365;
            newOpp.Description   = 'Renewal';
            newOpp.OwnerId       = O.OwnerId;
            newOpp.AccountId     = O.AccountId;
            renewalOpps.add(newOpp);
            Insert renewalOpps;
            OrgOpptoRenewOpp.put(O.Id, newOpp);
            
            system.debug('This is the Org Opp id Map to new Opp ' + O.Id +' ' + newOpp);

            //Find the primary CQs
                List <SCMC__Customer_Quotation__c> OriginalCQs = [SELECT ID,
                                                                 SCMC__Customer_Account__c,
                                                                 SCMC__Sales_Rep__c,
                                                                 SCMC__Opportunity__c
                                                            FROM SCMC__Customer_Quotation__c
                                                           WHERE SCMC__Opportunity__c = :O.Id
                                                             AND Primary__c = true];
            System.debug('Number of primary CQs = '+ OriginalCQs.size());
            
            //Find the primary CQLines
            List <SCMC__Customer_Quotation_Line__c> OriginalLines = [SELECT ID,
                                                                               SCMC__Item_Number__c,
                                                                               SCMC__Quantity__c,
                                                                               SCMC__Extend_Description__c,
                                                                               SCMC__Lookup_Manufacturer__c,
                                                                               SCMC__Customer_Quotation__r.id
                                                                          FROM SCMC__Customer_Quotation_Line__c
                                                                         WHERE SCMC__Customer_Quotation__c IN :OriginalCQs];
            
            System.debug('Number of CQLines = ' + OriginalLines.size());
            
            //Clone Quotes and Lines
            
            for(SCMC__Customer_Quotation__c OriginalQuote : OriginalCQs){
                
                SCMC__Customer_Quotation__c renewalCQ = new SCMC__Customer_Quotation__c();
                renewalCQ.SCMC__Customer_Account__c     = OriginalQuote.SCMC__Customer_Account__c;
                renewalCQ.SCMC__Sales_Rep__c            = OriginalQuote.SCMC__Sales_Rep__c;
                renewalCQ.SCMC__Opportunity__c          = OrgOpptoRenewOpp.get(OriginalQuote.SCMC__Opportunity__c).Id;
                renewalCQ.Primary__c                    = TRUE;
                renewalCQ.SCMC__Quotation_Expires_On__c = Date.today() + 365;
                renewalCQ.RecordTypeId                  = '012C0000000Qb0x';
                finalCustomerQuotations.add(renewalCQ);
                OrgCQtoRenewCQ.put(OriginalQuote.Id, renewalCQ);
                
                system.debug('map of ORG CQ to Renewal CQ ' + OriginalQuote.Id + ' ' + renewalCQ);
                
            }
            
            Insert finalCustomerQuotations;
            
            for(SCMC__Customer_Quotation_Line__c OriginalLine : OriginalLines){
                SCMC__Customer_Quotation_Line__c renewalLine = new SCMC__Customer_Quotation_Line__c();
                renewalLine.SCMC__Item_Number__c             = OriginalLine.SCMC__Item_Number__c;
                renewalLine.SCMC__Quantity__c                = OriginalLine.SCMC__Quantity__c;
                renewalLine.SCMC__Extend_Description__c      = OriginalLine.SCMC__Extend_Description__c;
                renewalLine.SCMC__Lookup_Manufacturer__c     = OriginalLine.SCMC__Lookup_Manufacturer__c;
                renewalLine.SCMC__Customer_Quotation__c      = OrgCQtoRenewCQ.get(OriginalLine.SCMC__Customer_Quotation__c).id;
                finalCQLines.add(renewalLine);
                
            }
    
        }
        
        
        Insert finalCQLines;
        
        system.debug('number of renewal opps created '+ renewalOpps.size());
        system.debug('number of renewal CQs created '+  finalCustomerQuotations.size());
        system.debug('number of renewal opps created '+ finalCQLines.size());
        
    }
    
}
Salesforce provides date literals you can use in your SOQL queries.  Here's their documentation - see page 20:

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_sobject_create.htm

When I run:
SELECT Id FROM Opportunity WHERE CloseDate = THIS_FISCAL_YEAR
through Dev console in my prod org, I get an invalid date error.  When I run queries in the same org using other date literals, like the example queries from the docs, they work fine.  That query executed in a partial sandbox doesn't work either.  That query executed in my own developer org works fine.

Anyone else ever experienced this?

There is an apex class in production that is using that query - and it's currently running fine.  Unfortunately, when we try to push changesets to prod and run all our unit tests, we get compilation errors on that class.  Our current workaround is to select specific unit tests to run when deploying to prod, however this solution is far less than ideal, and won't help if we need to make changes to that class.
In most of the emails I recieve, the subject contains a 6 digit "job number", which designates which assignment the email is about. Many of these emails come from the same email address, so the job number is the only way I can associate an incoming email with a specific opportunity. 

Is there any way to parse each incoming email subject to look for a 6 digit code?
I've searched around and read through the Instance Refresh Maintenance Knowledge Base article and I can't find an answer to this question.

I have an org on na23, which while soon go through a refresh and end up on na53.  I currently have a few custom email services within that org, both of which have email addresses with domains that end in "na23.apex.salesforce.com".  The domains for these email addresses are system generated - I can't change them.

When na23 gets refreshed and becomes na53, will the SFDC platform route emails sent to the current "na23.apex.salesforce.com" email addresses to my org where it resides on the new hardware?  Or do I need to coordinate with every 3rd party using those email addresses and have them switch to a new email address after the refresh - and if so, can I find out what the new email address will be ahead of time?  Will it be the same except for s/na23/na53/?
Here is the code: 

trigger AccountTrigger on Account (after update) {
    if(Trigger.IsUpdate && Trigger.IsAfter) {
        AccountTriggerHandler.handleAfterUpdate(Trigger.newMap, Trigger.oldMap);
    }
}
Hello,

We have received a heads up from Salesforce team that NA4 instance is going under refresh and whereever we have hardcoded references, we need to update them to make our org ready for the refresh.

I found that NA4 is being referrred in -
1) Flows- Purpose of the flow is to verify if a Contact already exists during creation and display an error message on the screen along with detail link of the contact. How should I take care of na4 references in the detail link to be updated?
2) Under Email-to-Case for one of the Email2Case Support group have Email Services Address references NA4.  does this requires any change? I believe as the routing email address already verified no action required. Kindly Clarify.

Please help me to sort this out.

Thank you.
I've only seen 1 other post about this issue and the resolution there isn't working for me.

I'm trying to mass move around 300 old reports to a specific folder using the Force.com IDE.  These are the steps I'm taking:

1) create a new Force.com project in Eclipse, including the metadata for reports
2) locally move the *.report metadata files for the reports I'd like to move to the folder where I want them
3) highlight the "reports" folder in the Package Explorer and choose "Force.com -> Save to Server"

The result is that a large portion of the reports are moved, however any report who's metadata xml includes the <currency> element isn't moved, and the error message for each of them is "Save error: currency: Unsupported currency: USD" (or EUR, or GBP - whatever currency is specified).

Anybody have any ideas on this?
The following code works fine:
List<Datetime> dtList = new List<Datetime>();
List<Object> oList = (List<Object>) dtList;

The following code, however, does not compile:
Set<Datetime> dtSet = new Set<Datetime>();
Set<Object> oSet = (Set<Object>) dtSet;

It results in a "Incompatible types since an instance of Set<Datetime> is never an instance of Set<Object>" compilation error.

Same thing here:
 
public class TestA {
}
public class TestB extends TestA {
}

List<TestB> tbList = new List<TestB>();
List<TestA> taList = (List<TestA>) tbList; // <--- compiles fine

Set<TestB> tbSet = new Set<TestB>();
Set<TestA> taSet = (Set<TestA>) tbSet;  // <--- doesn't compile
 
And here:
 
List<Account> aList = new List<Account>();
List<SObject> soList = (List<SObject>) aList; // <--- works fine

Set<Account> aSet = new Set<Account>();
Set<SObject> soSet = (Set<SObject>) aSet; // <--- compilation error
 
Am I missing something obvious?  If not, is there a reason you can't cast Sets like this?

Hello,

 

I was successful refreshing reports out of the sandbox into the IDE, cut and paste the reports to a different folder locally, then refresh and save to server in the sandbox to mass move reports (report cleanup)

 

Now when I do the same for the production region, the files won't save to the server. I get "File only saved locally, not to server" warnings and some errors " Save error: filters-criteriaItems-condition: Operator does not work with the selected column" and "Save error: curency:Unsupported currency:GBP" in the error logs. The rest of the reports save locally, not to the server.

 

Can anyone help me understand how I was successfully able to perform this task in the sandbox environment but not production?

 

Thanks

How do I go about getting all groups and it's members via a soql query?

 

SELECT Id, DeveloperName, GroupMember
FROM Group

 

I tried this and it gave me an error.