• Sai Harshitha Bandlamudi
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
I have a 3 level hierarchy. Object "School district" with picklist values "Zone 1","Zone 2","zone 3","zone 4". Each zone has their own level as picklist values such as "Level 1",Level 2", "Level 3" ",Level 4". If level 1 is chosen, the score is 1 and if level 2 is chosen the score is 2 and so on. Now i have to write a formula on "school district" level that does an aggregation of all zones( which is an aggregation of the minimun score of levels chosen)  returing the minmum values .

Example: "Zone 1 " if level 3 is chosen and 
in "Zone 2" if level 4 is chosen and 
in "Zone 3" if level 1 is chosen and 
In "Zone 4" if level 3 is chosen
 then at school district level it should return "1" as the value.
Hello All,
I am trying to implement S2S (Salesforce to salesforce) And I have written a code on Custom object called "ABC" to allow auto forwarding of records. After making the trigger active, I cannot manually create any records. Please help.

trigger SendABCToConnection on ABC__c(after insert,after update) {
        PartnerNetworkConnection conn = [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection  where ConnectionStatus = 'Accepted' and ConnectionName = 'XYZ'];
        List<PartnerNetworkRecordConnection> recordConnectionToInsert  = new List<PartnerNetworkRecordConnection>  ();
        for (ABC__c acc : Trigger.new){
            PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();

            newrecord.ConnectionId = conn.Id;
            newrecord.LocalRecordId = acc.id;  
            newrecord.SendClosedTasks = false;
            newrecord.SendOpenTasks = false;
            newrecord.SendEmails = false;
            recordConnectionToInsert.add(newrecord);
        }
        if (recordConnectionToInsert.size() > 0){
            System.debug('>>> Sharing ' + recordConnectionToInsert.size() + ' records');
            insert recordConnectionToInsert;
        }
     }

The error I am getting:
Apex trigger SendABCToConnection caused an unexpected exception, contact your administrator: SendABCToConnection: execution of AfterInsert caused by: System.QueryException: List has more than 1 row for assignment to SObject: Trigger.SendABCToConnection: line 2, column 1
I have a Object called "Object A" and it has a lookup with "object B" . 
I have forwarded object A into Target Org using the trigger:
trigger SendObjectAToConnection on ObjectA(after insert,after update) {
        PartnerNetworkConnection conn = [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection  where ConnectionStatus = 'Accepted' and ConnectionName = 'ABC'];
        List<PartnerNetworkRecordConnection> recordConnectionToInsert  = new List<PartnerNetworkRecordConnection>  ();
        
        for (ObjectA acc : Trigger.new){
            PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();

            newrecord.ConnectionId = conn.Id;
            newrecord.LocalRecordId = acc.id;  
            newrecord.SendClosedTasks = false;
            newrecord.SendOpenTasks = false;
            newrecord.SendEmails = false;
            recordConnectionToInsert.add(newrecord);
        }
        if (recordConnectionToInsert.size() > 0){
            System.debug('>>> Sharing ' + recordConnectionToInsert.size() + ' records');
            insert recordConnectionToInsert;
        }
     }
Similar Trigger for Object B. When I publish both objects into the Target Org, I donot know how to recreate their lookup relatuionship.

Similar trigger for 
When I try to create a new account, It throws me an error saying:Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger SendAccountsToConnection caused an unexpected exception, contact your administrator: SendAccountsToConnection: execution of AfterInsert caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.SendAccountsToConnection: line 2, column 1
trigger SendAccountsToConnection on Account(after insert,after update) { PartnerNetworkConnection conn = [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted' and ConnectionName = 'Johnson Controls']; List<PartnerNetworkRecordConnection> recordConnectionToInsert = new List<PartnerNetworkRecordConnection> (); for (Account acc : Trigger.new){ PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection(); newrecord.ConnectionId = conn.Id; newrecord.LocalRecordId = acc.id; newrecord.SendClosedTasks = false; newrecord.SendOpenTasks = false; newrecord.SendEmails = false; recordConnectionToInsert.add(newrecord); } if (recordConnectionToInsert.size() > 0){ System.debug('>>> Sharing ' + recordConnectionToInsert.size() + ' records'); insert recordConnectionToInsert; } }
​

trigger SendAccountsToConnection on Account(after insert,after update) {
        PartnerNetworkConnection conn = [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection  where ConnectionStatus = 'Accepted' and ConnectionName = 'abc'];
        List<PartnerNetworkRecordConnection> recordConnectionToInsert  = new List<PartnerNetworkRecordConnection>  ();
        
        for (Account acc : Trigger.new){
            PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();

            newrecord.ConnectionId = conn.Id;
            newrecord.LocalRecordId = acc.id;  
            newrecord.SendClosedTasks = false;
            newrecord.SendOpenTasks = false;
            newrecord.SendEmails = false;
            recordConnectionToInsert.add(newrecord);
        }
        if (recordConnectionToInsert.size() > 0){
            System.debug('>>> Sharing ' + recordConnectionToInsert.size() + ' records');
            insert recordConnectionToInsert;
        }
     }

 
When I try to create a new account, It throws me an error saying:Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger SendAccountsToConnection caused an unexpected exception, contact your administrator: SendAccountsToConnection: execution of AfterInsert caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.SendAccountsToConnection: line 2, column 1
trigger SendAccountsToConnection on Account(after insert,after update) { PartnerNetworkConnection conn = [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted' and ConnectionName = 'Johnson Controls']; List<PartnerNetworkRecordConnection> recordConnectionToInsert = new List<PartnerNetworkRecordConnection> (); for (Account acc : Trigger.new){ PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection(); newrecord.ConnectionId = conn.Id; newrecord.LocalRecordId = acc.id; newrecord.SendClosedTasks = false; newrecord.SendOpenTasks = false; newrecord.SendEmails = false; recordConnectionToInsert.add(newrecord); } if (recordConnectionToInsert.size() > 0){ System.debug('>>> Sharing ' + recordConnectionToInsert.size() + ' records'); insert recordConnectionToInsert; } }
​

trigger SendAccountsToConnection on Account(after insert,after update) {
        PartnerNetworkConnection conn = [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection  where ConnectionStatus = 'Accepted' and ConnectionName = 'abc'];
        List<PartnerNetworkRecordConnection> recordConnectionToInsert  = new List<PartnerNetworkRecordConnection>  ();
        
        for (Account acc : Trigger.new){
            PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();

            newrecord.ConnectionId = conn.Id;
            newrecord.LocalRecordId = acc.id;  
            newrecord.SendClosedTasks = false;
            newrecord.SendOpenTasks = false;
            newrecord.SendEmails = false;
            recordConnectionToInsert.add(newrecord);
        }
        if (recordConnectionToInsert.size() > 0){
            System.debug('>>> Sharing ' + recordConnectionToInsert.size() + ' records');
            insert recordConnectionToInsert;
        }
     }