You need to sign in to do that
Don't have an account?
Sai Harshitha Bandlamudi
Trigger error:List has no rows for assignment to SObject
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
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; } }
What is there in the line no. 2 ? If this is the code, then this query is returning no data. Please try to execute it from dataloader or qorkbench to see if there is data and then correct in the trigger.
PartnerNetworkConnection conn = [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted' and ConnectionName = 'Johnson Controls'];
Please let me know if this is helpful.
regards,
Shashi
All Answers
What is there in the line no. 2 ? If this is the code, then this query is returning no data. Please try to execute it from dataloader or qorkbench to see if there is data and then correct in the trigger.
PartnerNetworkConnection conn = [select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted' and ConnectionName = 'Johnson Controls'];
Please let me know if this is helpful.
regards,
Shashi