You need to sign in to do that
Don't have an account?
Fill in account from case to the contact from quick create
When a service rep creates a case from an account they may create a contact by using the Quick Craete button. We know this quick create feature coes not allow the user to select an account. I have a trigger that should grab the Account id and contact IDs on the case and add the Account on the case to the newly created contact. I finally got past the errors but nw nothing happens.
trigger QuickContactUpdate on Case (after insert, after update) { String CPMCase = 'CPM Case'; Map<String, Schema.RecordTypeInfo> CaseType = new Map<String, Schema.RecordTypeInfo>(); CaseType = Schema.SObjectType.Case.getRecordTypeInfosByName(); String CaseTypeId = CaseType.get(CPMCase).getRecordTypeId(); List<ID> CaseList = new list<ID>(); for (Case c : Trigger.new) { IF(c.RecordTypeID == CaseTypeID && c.contact != NULL && c.account != NULL){ CaseList.add(c.id); } } Map<string,string> ConID = New Map<string,string>(); FOR(Case CaseConnect:[SELECT ContactID, AccountID FROM Case WHERE AccountID != NULL AND contact.AccountID = null AND ID IN :CaseList]){ ConID.put(CaseConnect.ContactID,CaseConnect.AccountID); FOR(Contact ConCorrect:[SELECT ID, AccountID FROM Contact WHERE ID in :ConID.KeySet()]){ ConCorrect.AccountID = ConID.get(ConCorrect.ID); UPDATE ConCorrect; } } }
Any thoughts on what I'm missing?
I think you should be able to get to the same result without coding.
I would create a custom button which pops the actual contact page pre-populated with Account Id from Case - haven't tried it, but it seems like it would be possible.
This is a good thread to get going
https://success.salesforce.com/answers?id=90630000000giziAAA
The problem with this is that it takes extra clicks to then go back to the case and lookup that user and then add them. I have a high volume call center where every click matters. Here is another code that still didn't work.
I got the account to update the contact!!!!! But now it does it every time. I think it has something to do with how I check for a null value for the contact's account field (c1.contact.accountID==null) .