trigger AutoShareTasks on Task (before insert) {
List<PartnerNetworkConnection> connMap = new List<PartnerNetworkConnection>([select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted']);
List<PartnerNetworkRecordConnection> prncList = new List<PartnerNetworkRecordConnection>();
for(Task t : Trigger.new){
String tId = t.id;
for(PartnerNetworkConnection network : connMap){
String cid = network.Id;
String status = network.ConnectionStatus;
String connName = network.ConnectionName;
String TaskName = t.Subject;
String OpportunityID = t.whatid;
String CreatedBy = t.CreatedBy.name;
if(TaskName != NULL && t.CreatedBy.name != 'Connection User'){
PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
newrecord.ConnectionId = cid;
newrecord.LocalRecordId = tid;
newrecord.ParentRecordId= OpportunityID;
insert newrecord;
}
}
}
}
1 answer
This Answers Community is focused on configuration and design questions. Programmatic questions are best submitted to
the developer forums at https://developer.salesforce.com where the forums and participants are geared toward programming troubleshooting and support.