Created
January 3, 2020 16:20
-
-
Save mhamzas/60d104905dc223c334b01ef6c663f5fa to your computer and use it in GitHub Desktop.
This Trigger will share the newly created case i.e. S2S.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Trigger Name : AutoCaseSharing | |
| * Author : Hamza @ CloudJunction | |
| * Date Creation : 10/15/2018 01:29 GMT+5 | |
| * Last Date Modified : 10/15/2018 02:31 GMT+5 | |
| * Description : This Trigger will share the newly created case i.e. S2S. | |
| * | |
| */ | |
| trigger AutoCaseSharing on Case (after insert) { | |
| List<PartnerNetworkRecordConnection> NetworkList = new List<PartnerNetworkRecordConnection>(); | |
| List<PartnerNetworkConnection> conn = new List<PartnerNetworkConnection>(); | |
| //Fetching ConnectionId | |
| conn = [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted' limit 1]; | |
| // After Insert | |
| if(Trigger.isInsert && Trigger.isAfter) | |
| { | |
| //Looping throught new cases | |
| for(case c: Trigger.new){ | |
| //Initializing Network Record Connection | |
| PartnerNetworkRecordConnection newConnection = | |
| new PartnerNetworkRecordConnection( | |
| ConnectionId = conn[0].Id, | |
| LocalRecordId = c.Id, | |
| SendClosedTasks = false, | |
| SendOpenTasks = false, | |
| SendEmails = false | |
| //ParentRecordId = c.AccountId | |
| ); | |
| //Adding Connection Record in List | |
| NetworkList.add(newConnection); | |
| } | |
| //Inserting NetworkConnection Record. | |
| if (NetworkList.size() > 0 ) { | |
| //database.insert(NetworkList); | |
| insert NetworkList; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment