- goutham.tatineni1.3893010493585044E12
- NEWBIE
- 20 Points
- Member since 2014
-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
5Questions
-
5Replies
Issue with Apex Save method while creating parent and Child record at same time
HI ,
I have a Parent Object (Client Site) and Child Object (Client Supplier ). What i am trying to acheive is i am trying to create 1 parent and multiple child records at the same time .Everything is working perfectly except I have one issue while i cretae a parent 1 Child record is created by deafult even if i do not want to .
I have a Parent Object (Client Site) and Child Object (Client Supplier ). What i am trying to acheive is i am trying to create 1 parent and multiple child records at the same time .Everything is working perfectly except I have one issue while i cretae a parent 1 Child record is created by deafult even if i do not want to .
public class AddClientSupplier { ApexPages.StandardController sc; public Client_Site__c acct{get;set;} public Integer marker=2; public Integer selectedClientSupplier{get;set;} public List<WrapperClass> lClientSuppliers{get;set;} public AddClientSupplier(ApexPages.StandardController controller) { this.acct = (Client_Site__c)controller.getRecord(); sc=controller; lClientSuppliers=new List<WrapperClass>(); Client_Supplier__c c=new Client_Supplier__c(); lClientSuppliers.add(new WrapperClass(c,1)); } public PageReference deleteClientSupplier(){ Integer x=-1; for(WrapperClass wc:lClientSuppliers){ x++; if(wc.counter==selectedClientSupplier){ System.debug('-->selected ClientSupplier:'+selectedClientSupplier+' position:'+x); break; } } lClientSuppliers.remove(x); return null; } public PageReference saveClientSite(){ Database.SaveResult sr = Database.insert(acct, false); Id idey=sr.getId(); List<Client_Supplier__c> ClientSupplierList=new List<Client_Supplier__c>(); for(WrapperClass wc:lClientSuppliers){ Client_Supplier__c c=new Client_Supplier__c(); c.Is_This_a_New_or_Incumbent_Supplier__c=wc.c.Is_This_a_New_or_Incumbe nt_Supplier__c; c.Skill_Type__c=wc.c.Skill_Type__c; c.Supplier_Name__c=wc.c.Supplier_Name__c; c.Will_Manpower_Manage_This_Supplier__c=wc.c.Will_Manpower_Manage_Thi s_Supplier__c; c.Client_Site__c=idey; ClientSupplierList.add(c); } insert ClientSupplierList; return(new PageReference('/'+sr.id).setRedirect(True)); } public PageReference addAClientSupplier(){ Client_Supplier__c c=new Client_Supplier__c(); lClientSuppliers.add(new WrapperClass(c,marker)); marker=marker+1; return null; } public class WrapperClass{ public Integer counter{get;set;} public Client_Supplier__c c{get;set;} public WrapperClass(Client_Supplier__c cntc,Integer i){ this.c=cntc; this.counter=i; } } }
<apex:page standardController="Client_Site__c" extensions="AddClientSupplier,ClientSiteExt" tabStyle="Client_Site__c"> <apex:form id="myForm" > <apex:sectionHeader title="New Client Site" /> <apex:pageBlock title=" Client Site Edit" mode="edit"> <apex:pageBlockButtons location="top" > <apex:commandButton value="Save" action="{!saveClientSite}" /> <apex:commandButton value="Cancel" action="{!Cancel}"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Information" columns="2"> <apex:inputField value="{!Client_Site__c.Client_Site_Name__c}" taborderhint="1"/> <apex:inputField value="{!Client_Site__c.Client_Discovery__c}" taborderhint="6"/> <apex:inputField value="{!Client_Site__c.City__c}" taborderhint="2"/> <apex:inputField value="{!Client_Site__c.Number_of_Shifts__c}" taborderhint="7"/> <apex:inputField value="{!Client_Site__c.State__c}" taborderhint="3"/> <apex:inputField value="{!Client_Site__c.Number_of_Team_Leads__c}" taborderhint="8"/> <apex:inputField value="{!Client_Site__c.Head_count__c}" taborderhint="4"/> <apex:inputField value="{!Client_Site__c.Number_of_On_Site_Managers__c}" taborderhint="9"/> <apex:inputField value="{!Client_Site__c.Job_Titles__c}" taborderhint="5"/> <apex:inputField value="{!Client_Site__c.Union_or_Non_Union__c}" taborderhint="10"/> </apex:pageBlockSection> <apex:pageBlockSection title="Client Suppliers" columns="4"> </apex:pageBlockSection> <apex:repeat value="{!lClientSuppliers}" var="x"> <apex:panelGrid columns="6"> <apex:panelGrid > <apex:facet name="header">Client Supplier Name</apex:facet> <apex:inputField value="{!x.c.Supplier_Name__c}" style="width:200px" /> </apex:panelGrid> <apex:panelGrid > <apex:facet name="header">Is This a New or Incumbent Supplier?y</apex:facet> <apex:inputField value="{!x.c.Is_This_a_New_or_Incumbent_Supplier__c}" style="width:200px" /> </apex:panelGrid> <apex:panelGrid > <apex:facet name="header">Skill Type</apex:facet> <apex:inputField value="{!x.c.Skill_Type__c}" style="width:200px"/> </apex:panelGrid> <apex:panelGrid > <apex:facet name="header"> Will Manpower manage this supplier?</apex:facet> <apex:inputField value="{!x.c.Will_Manpower_Manage_This_Supplier__c}" style="width:200px" /> </apex:panelGrid> <apex:panelGrid > </apex:panelGrid> <apex:commandButton action="{!deleteClientSupplier}" style="Button" value="Delete ClientSite" reRender="myForm" immediate="true"> <apex:param value="{!x.counter}" name="selected" assignTo="{!selectedContact}"/> </apex:commandButton> </apex:panelGrid> </apex:repeat> <apex:pageBlockButtons location="bottom"> <apex:panelGrid ></apex:panelGrid> <apex:commandButton value="Add Client Supplier" action="{!addAClientSupplier}" reRender="myForm" immediate="true" /> <apex:commandButton value="Save" action="{!saveClientSite}" /> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
-
- goutham.tatineni1.3893010493585044E12
- September 24, 2015
- Like
- 0
Old Test Class passes in UAT fails in Production
Hi Something strange happening all of a sudden .I am trying to deploy some code to proiduction and i am having 4 ols test classes failuers . All those classes were not modified recently nor any new validations or workfl;ows around them . Could some one help me out please
All my test classes are failing with same erorr System.QueryException: List has no rows for assignment to SObject
Same code in prod and sandbox since 2012 and not modifed since then.Here are the errors i get in production
System.QueryException: List has no rows for assignment to SObject (Same error For all the below methods)
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNOTNullAndTypeNOTNull: line 79, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNullAndTypeIsSentEmail: line 112, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNullAndTypeNOTNull: line 129, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.modifyMeetingTypeAndEventType: line 173, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.modifyOnlyEventType: line 200, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.modifyOnlyMeetingType: line 147, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNOTNullAndTypeIsNull: line 63, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNOTNullAndTypeIsSentEmail: line 95, column 1
All my test classes are failing with same erorr System.QueryException: List has no rows for assignment to SObject
@isTest private class TestUpdateEvents { private static Account acc{get;set;} private static User usr{get;set;} private static Profile p{get;set;} private static List<Event> EventsList{get;set;} /* Input: The standard type and Activity Type are passed in as parameters. Process: Inserts Event records. Output: 20 Events are created. Changes: */ static void createTestdata(String Eventtype, String MeetingType) { acc = new Account (name = 'TestUpdateEvents',phone='111111',BillingCity = 'TestUpdateEventsCity', BillingCountry ='TestUpdateEventsCountry', BillingStreet ='TestUpdateEventsStreet', BillingPostalCode ='updateEvent'); insert acc; p = [select id from profile where name='Sales Pro']; String[] environment = Userinfo.getUserName().split('@'); usr = new User(FirstName ='TestFirstName',Lastname= 'Testlastname',alias = 'Tst',email= 'TestFirstName1.Testlastname1@mpg.com', profileid = TestUpdateEvents.p.Id,username= 'TestFirstName'+ 'Testlastname'+'@'+environment[1],emailencodingkey='UTF-8', languagelocalekey='en_US',localesidkey='en_US',timezonesidkey='America/Los_Angeles', Country ='USA', CompanyName = 'Manpower',Brand__c = 'ManpowerGroup',Region__c = 'Corporate',Sub_Region__c = 'Corporate'); insert usr; EventsList = new List<Event>(); for(Integer i = 0; i < 20;i++) { Event e = new Event(); e.OwnerId = usr.Id; e.WhatId = acc.Id; e.Type = Eventtype; e.Meeting_Type__c = MeetingType; e.Subject='Test'+i; // t.Status = 'Not Started' ; // t.Priority = 'Normal' ; e.ActivityDate = Date.today() + 10; e.StartDateTime = Date.today() ; e.endDateTime = Date.today(); EventsList.add(e); } insert EventsList; } /* Input: No input variables Process: Insert Event records whose Type is null and Activity_Type is 'Call' Output: Validate the type field. It should be updated to Call Changes: None */ static testMethod void MeetingTypeNOTNullAndTypeIsNull() { createTestdata(null,'Call'); List<Event> insertedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< insertedEvents.size(); i ++) { System.assertEquals('Call', insertedEvents[i].Type); System.assertEquals('Call', insertedEvents[i].Meeting_Type__c); } } /* Input: No input variables Process: Insert Event records whose Type is 'Other' and Activity_Type is 'Call' Output: Validate the type field. It should be updated to Call Changes: None */ static testMethod void MeetingTypeNOTNullAndTypeNOTNull() { createTestdata('Other','Call'); List<Event> insertedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< insertedEvents.size(); i ++) { System.assertEquals('Call', insertedEvents[i].Type); System.assertEquals('Call', insertedEvents[i].Meeting_Type__c); } } /* Input: No input variables Process: Insert Event records whose Type is 'Sent E-mail' and Activity_Type is 'Call' Output: Validate the type and Activity_Type fields. Activity_Type should be updated to Sent E-mail. Changes: None */ static testMethod void MeetingTypeNOTNullAndTypeIsSentEmail() { createTestdata('Sent E-mail','Call'); List<Event> insertedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< insertedEvents.size(); i ++) { System.assertEquals('Sent E-mail', insertedEvents[i].Type); System.assertEquals('Sent E-mail', insertedEvents[i].Meeting_Type__c); } } /* Input: No input variables Process: Insert Event records whose Type is 'Sent E-mail' and Activity_Type is 'null' Output: Validate the Activity_Type field. It should be updated to Sent E-mail Changes: None */ static testMethod void MeetingTypeNullAndTypeIsSentEmail() { createTestdata('Sent E-mail',null); List<Event> insertedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< insertedEvents.size(); i ++) { System.assertEquals('Sent E-mail', insertedEvents[i].Type); System.assertEquals('Sent E-mail', insertedEvents[i].Meeting_Type__c); } } /* Input: No input variables Process: Insert Event records whose Type is 'Call' and Activity_Type is 'null' Output: Validate the type and Activity_Type fields. They should be updated to Call Changes: None */ static testMethod void MeetingTypeNullAndTypeNOTNull() { createTestdata('Call',null); List<Event> insertedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< insertedEvents.size(); i ++) { System.assertEquals('Call', insertedEvents[i].Type); System.assertEquals('Call', insertedEvents[i].Meeting_Type__c); } } /* Input: No input variables Process: Insert Event records whose Type is 'null' and Activity_Type is 'Call'. Then update the activity_Type from 'Call' to 'RFI' Output: Validate the type and Activity_Type fields. They should be updated to RFI. Changes: None */ static testMethod void modifyOnlyMeetingType() { createTestdata(null,'Call'); List<Event> updateEvents = new List<Event>(); updateEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< updateEvents.size(); i ++) { updateEvents[i].Meeting_Type__c = 'RFI'; } update updateEvents; List<Event> updatedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: updateEvents ORDER BY Id]; for(Integer i = 0;i< updatedEvents.size(); i ++) { System.assertEquals('RFI', updatedEvents[i].Type); System.assertEquals('RFI', updatedEvents[i].Meeting_Type__c); } } /* Input: No input variables Process: Insert Event records whose Type is 'null' and Activity_Type is 'Call'. Then update the activity_Type to 'Sent E-mail' and Type to 'Other' Output: Validate the type and Activity_Type fields. They should be updated to Sent E-mail. Changes: None */ static testMethod void modifyMeetingTypeAndEventType() { createTestdata(null,'Call'); List<Event> updateEvents = new List<Event>(); updateEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< updateEvents.size(); i ++) { updateEvents[i].Meeting_Type__c = 'Sent E-mail'; updateEvents[i].Type = 'Other'; } update updateEvents; List<Event> updatedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: updateEvents ORDER BY Id]; for(Integer i = 0;i< updatedEvents.size(); i ++) { System.assertEquals('Sent E-mail', updatedEvents[i].Type); System.assertEquals('Sent E-mail', updatedEvents[i].Meeting_Type__c); } } /* Input: No input variables Process: Insert Event records whose Type is 'null' and Activity_Type is 'Call'. Then update the standard Type to 'Sent E-mail' Output: Validate the type and Activity_Type fields. They should be updated to Sent E-mail. Changes: None */ static testMethod void modifyOnlyEventType() { createTestdata(null,'Call'); List<Event> updateEvents = new List<Event>(); updateEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< updateEvents.size(); i ++) updateEvents[i].Type = 'Sent E-mail'; update updateEvents; List<Event> updatedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: updateEvents ORDER BY Id]; for(Integer i = 0;i< updatedEvents.size(); i ++) { System.assertEquals('Sent E-mail', updatedEvents[i].Type); System.assertEquals('Sent E-mail', updatedEvents[i].Meeting_Type__c); } } }
Same code in prod and sandbox since 2012 and not modifed since then.Here are the errors i get in production
System.QueryException: List has no rows for assignment to SObject (Same error For all the below methods)
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNOTNullAndTypeNOTNull: line 79, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNullAndTypeIsSentEmail: line 112, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNullAndTypeNOTNull: line 129, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.modifyMeetingTypeAndEventType: line 173, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.modifyOnlyEventType: line 200, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.modifyOnlyMeetingType: line 147, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNOTNullAndTypeIsNull: line 63, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNOTNullAndTypeIsSentEmail: line 95, column 1
-
- goutham.tatineni1.3893010493585044E12
- September 04, 2015
- Like
- 0
An error occurred when processing your submitted information when saving
<apex:page controller="CustomContactLookupController" title="Search" showHeader="false" sideBar="false" tabStyle="Contact" id="pg"> <apex:form > <apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;"> <apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel"> <!-- SEARCH TAB --> <apex:tab label="Contact Search" name="tab1" id="tabOne"> <apex:actionRegion > <apex:outputPanel id="top" layout="block" style="margin:1px;padding:10px;padding-top:2px;"> <apex:outputLabel value="{!$Label.OptyContRolePage_Search_Button}" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/> <apex:inputText id="txtSearch" value="{!searchString}"/> <span style="padding-left:5px"> <apex:commandButton id="btnGo" value="{!$Label.OptyContRolePage_Go_Button}" action="{!Search}" rerender="searchResults"> </apex:commandButton> </span> </apex:outputPanel> <apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;font-size:small" layout="block"> <apex:outputLabel value="{!$Label.OptyContRolePage_ResultSection}" style="font-weight:Bold;padding-right:10px;"/> <br/><br/> <apex:pageBlock id="searchResults" title="Contacts[{!searchContactCount}]"> <apex:pageBlockTable value="{!results}" var="a" id="tblResults"> <apex:column > <apex:facet name="header"> <apex:outputPanel >Name</apex:outputPanel> </apex:facet> <apex:outputLink value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!a.Name}',false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Name}</apex:outputLink> </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >Client Name</apex:outputPanel> </apex:facet> <apex:outputText value="{!a.Account.Name}" rendered="{!NOT(ISNULL(a.Id))}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >Phone</apex:outputPanel> </apex:facet> <apex:outputText value="{!a.Phone}" rendered="{!NOT(ISNULL(a.Id))}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >Email</apex:outputPanel> </apex:facet> <apex:outputText value="{!a.Email}" rendered="{!NOT(ISNULL(a.Id))}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:outputPanel> </apex:actionRegion> </apex:tab> <apex:tab label="New Contact" name="tab2" id="tabTwo"> <apex:pageBlock id="newContact" title="New Contact"> <apex:pageBlockButtons > <apex:commandButton action="{!SaveContact}" value="Save"/> </apex:pageBlockButtons> <apex:pageMessages /> <apex:pageBlockSection columns="2"> <apex:repeat value="{!$ObjectType.Contact.FieldSets.CustomContactLookup}" var="f"> <apex:inputField value="{!Contact[f]}"/> </apex:repeat> <!-- <apex:inputField value="{!Contact.LastName}"/> <apex:inputField value="{!Contact.Email}"/> <apex:inputField value="{!Contact.AccountID}"/> --> </apex:pageBlockSection> </apex:pageBlock> </apex:tab> </apex:tabPanel> </apex:outputPanel> </apex:form> </apex:page>
public with sharing class CustomContactLookupController { public Contact Contact {get;set;} // new Contact to create public List<Contact> results{get;set;} // search results public string searchString{get;set;} // search keyword public Id ultiAccId; public Id localAccId; public Integer searchContactCount {get;set;} public CustomContactLookupController() { // get the current search string searchString = System.currentPageReference().getParameters().get('lksrch'); ultiAccId = System.currentPageReference().getParameters().get('ultimateAccId'); localAccId= System.currentPageReference().getParameters().get('localAccId'); runSearch(); } // performs the keyword search public PageReference search() { searchContactCount = 0; runSearch(); return null; } // prepare the query and issue the search command private void runSearch() { // TODO prepare query string for complex serarches & prevent injections results = performSearch(searchString); } // run the search and return the records found. private List<Contact> performSearch(string searchString) { //String[] tokens; //String accIds; List<Account> SudsidaryAccounts = [select Id from Account where Ultimate_Parent_Client__c =:ultiAccId and id!=null limit 10000]; List<String> accIds = new List<String>(); accIds.add(ultiAccId); for(Account acc : SudsidaryAccounts) { accIds.add(acc.Id); } List<contact> conts = [select id, name,AccountId,Email,Phone,Account.Name from Contact where Name LIKE: '%'+searchString +'%' and AccountId IN: accIds]; searchContactCount = conts.size(); return conts; } // save the new Contact record public PageReference saveContact() { insert Contact; // reset the Contact Contact = new Contact(); return null; } // used by the visualforce page to send the link to the right dom element public string getFormTag() { return System.currentPageReference().getParameters().get('frm'); } // used by the visualforce page to send the link to the right dom element for the text box public string getTextBox() { return System.currentPageReference().getParameters().get('txt'); } }
When i save the record in a LookUp , This weird error comes up. Any idea why this is happening.
-
- goutham.tatineni1.3893010493585044E12
- April 06, 2015
- Like
- 0
Help With Test class for Batch Apex on Opportunity Line Item
System.UnexpectedException: No more than one executeBatch can be called from within a testmethod. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation.
@isTest(seeAllData=true) private class TestConversionRate { @isTest static void MyUnitTest() { // Set up some local variables String opportunityName = 'My Opportunity'; String standardPriceBookId = ''; PriceBook2 pb2Standard = [select Id from Pricebook2 where isStandard=true]; standardPriceBookId = pb2Standard.Id; Account a = new Account(Name = 'Berlington'); Insert a; // set up opp and Verify that the results are as expected. Opportunity o = new Opportunity(AccountId = a.id, Name=opportunityName, StageName='Discovery', CloseDate=Date.today()); insert o; Opportunity opp = [SELECT Name FROM Opportunity WHERE Id = :o.Id]; //System.assertEquals(opportunityName, 'Berlington - 0 -'); // set up product2 and Verify that the results are as expected. Product2 p2 = new Product2(Name='Test Product',isActive=true); insert p2; Product2 p2ex = [SELECT Name FROM Product2 WHERE Id = :p2.Id]; //System.assertEquals('Test Product', p2ex.Name); // set up PricebookEntry and Verify that the results are as expected. PricebookEntry pbe = new PricebookEntry(Pricebook2Id=standardPriceBookId, Product2Id=p2.Id, UnitPrice=99, isActive=true); insert pbe; PricebookEntry pbeex = [SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbe.Id]; //System.assertEquals(standardPriceBookId, pbeex.Pricebook2Id); Win_Rate__c w = new Win_Rate__c(Name = 'Manpower - Brazil - 121-180',Win_rate__c = 90 ); Insert W; // set up OpportunityLineItem and Verify that the results are as expected. OpportunityLineItem oli = new OpportunityLineItem(PriceBookEntryId=pbe.Id, OpportunityId=o.Id,WinRate__c = w.id,Hidden_Name__c = w.name, Quantity=1, TotalPrice=99); insert oli; OpportunityLineItem oliex = [SELECT PriceBookEntryId FROM OpportunityLineItem WHERE Id = :oli.Id]; System.assertEquals(pbe.Id, oliex.PriceBookEntryId); opportunityLineItem Oppl = [Select Id,Name ,WinRate__c ,Hidden_Name__c from OpportunityLineItem where id =:oli.id]; system.assertnotEquals(oppl.WinRate__c ,''); } static testMethod void BatchProcessAccount_TestMethod (){ Test.StartTest(); UpdateWinRateBatch objBatch = new UpdateWinRateBatch(); ID batchprocessid = Database.executeBatch(objBatch); Test.StopTest(); } }
-
- goutham.tatineni1.3893010493585044E12
- July 24, 2014
- Like
- 0
Share primary Contacts along with the Opportunity using Sales Force to Sales Force Connector
Hi ,
Lead - gets converted to an Account , Contact and an Opportunity
I developed a trigger which shares an Opportunity and realted Account with another Org of ours, and the peice i am missing is sharing the Contact along with this . Need some help for sharing the contact also.
Trigger autoforwardOpportunity on Opportunity(after insert) {
String UserName = UserInfo.getName();
String orgName = UserInfo.getOrganizationName();
List<PartnerNetworkConnection> connMap = new List<PartnerNetworkConnection>(
[select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted']
);
System.debug('Size of connection map: '+connMap.size());
List<PartnerNetworkRecordConnection> prncList = new List<PartnerNetworkRecordConnection>();
for(Integer i =0; i< Trigger.size; i++) {
Opportunity acc = Trigger.new[i];
String acId = acc.Id;
System.debug('Value of OpportunityId: '+acId);
for(PartnerNetworkConnection network : connMap) {
String cid = network.Id;
String status = network.ConnectionStatus;
String connName = network.ConnectionName;
String AssignedBusinessUnit = acc.Assigned_Business_Unit__c;
System.debug('Connectin Details.......Cid:::'+cid+'Status:::'+Status+'ConnName:::'+connName+','+AssignedBusinessUnit);
if(AssignedBusinessUnit!=Null && (AssignedBusinessUnit.equalsIgnoreCase('IT') || AssignedBusinessUnit.equalsIgnoreCase('Proservia'))) {
// Send account to IT instance
PartnerNetworkRecordConnection newAccount = new PartnerNetworkRecordConnection();
newAccount.ConnectionId = cid;
newAccount.LocalRecordId = acc.AccountId;
newAccount.SendClosedTasks = true;
newAccount.SendOpenTasks = true;
newAccount.SendEmails = true;
newAccount.RelatedRecords = 'Contact';
System.debug('Inserting New Record'+newAccount);
insert newAccount;
// Send opportunity to IT instance
PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
newrecord.ConnectionId = cid;
newrecord.LocalRecordId = acId;
newrecord.SendClosedTasks = true;
newrecord.SendOpenTasks = true;
newrecord.SendEmails = true;
//newrecord.ParentRecordId = acc.AccountId;
System.debug('Inserting New Record'+newrecord);
insert newrecord;
}
}
Thanks
G.
}
}
Lead - gets converted to an Account , Contact and an Opportunity
I developed a trigger which shares an Opportunity and realted Account with another Org of ours, and the peice i am missing is sharing the Contact along with this . Need some help for sharing the contact also.
Trigger autoforwardOpportunity on Opportunity(after insert) {
String UserName = UserInfo.getName();
String orgName = UserInfo.getOrganizationName();
List<PartnerNetworkConnection> connMap = new List<PartnerNetworkConnection>(
[select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted']
);
System.debug('Size of connection map: '+connMap.size());
List<PartnerNetworkRecordConnection> prncList = new List<PartnerNetworkRecordConnection>();
for(Integer i =0; i< Trigger.size; i++) {
Opportunity acc = Trigger.new[i];
String acId = acc.Id;
System.debug('Value of OpportunityId: '+acId);
for(PartnerNetworkConnection network : connMap) {
String cid = network.Id;
String status = network.ConnectionStatus;
String connName = network.ConnectionName;
String AssignedBusinessUnit = acc.Assigned_Business_Unit__c;
System.debug('Connectin Details.......Cid:::'+cid+'Status:::'+Status+'ConnName:::'+connName+','+AssignedBusinessUnit);
if(AssignedBusinessUnit!=Null && (AssignedBusinessUnit.equalsIgnoreCase('IT') || AssignedBusinessUnit.equalsIgnoreCase('Proservia'))) {
// Send account to IT instance
PartnerNetworkRecordConnection newAccount = new PartnerNetworkRecordConnection();
newAccount.ConnectionId = cid;
newAccount.LocalRecordId = acc.AccountId;
newAccount.SendClosedTasks = true;
newAccount.SendOpenTasks = true;
newAccount.SendEmails = true;
newAccount.RelatedRecords = 'Contact';
System.debug('Inserting New Record'+newAccount);
insert newAccount;
// Send opportunity to IT instance
PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
newrecord.ConnectionId = cid;
newrecord.LocalRecordId = acId;
newrecord.SendClosedTasks = true;
newrecord.SendOpenTasks = true;
newrecord.SendEmails = true;
//newrecord.ParentRecordId = acc.AccountId;
System.debug('Inserting New Record'+newrecord);
insert newrecord;
}
}
Thanks
G.
}
}
-
- goutham.tatineni1.3893010493585044E12
- February 24, 2014
- Like
- 1
Share primary Contacts along with the Opportunity using Sales Force to Sales Force Connector
Hi ,
Lead - gets converted to an Account , Contact and an Opportunity
I developed a trigger which shares an Opportunity and realted Account with another Org of ours, and the peice i am missing is sharing the Contact along with this . Need some help for sharing the contact also.
Trigger autoforwardOpportunity on Opportunity(after insert) {
String UserName = UserInfo.getName();
String orgName = UserInfo.getOrganizationName();
List<PartnerNetworkConnection> connMap = new List<PartnerNetworkConnection>(
[select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted']
);
System.debug('Size of connection map: '+connMap.size());
List<PartnerNetworkRecordConnection> prncList = new List<PartnerNetworkRecordConnection>();
for(Integer i =0; i< Trigger.size; i++) {
Opportunity acc = Trigger.new[i];
String acId = acc.Id;
System.debug('Value of OpportunityId: '+acId);
for(PartnerNetworkConnection network : connMap) {
String cid = network.Id;
String status = network.ConnectionStatus;
String connName = network.ConnectionName;
String AssignedBusinessUnit = acc.Assigned_Business_Unit__c;
System.debug('Connectin Details.......Cid:::'+cid+'Status:::'+Status+'ConnName:::'+connName+','+AssignedBusinessUnit);
if(AssignedBusinessUnit!=Null && (AssignedBusinessUnit.equalsIgnoreCase('IT') || AssignedBusinessUnit.equalsIgnoreCase('Proservia'))) {
// Send account to IT instance
PartnerNetworkRecordConnection newAccount = new PartnerNetworkRecordConnection();
newAccount.ConnectionId = cid;
newAccount.LocalRecordId = acc.AccountId;
newAccount.SendClosedTasks = true;
newAccount.SendOpenTasks = true;
newAccount.SendEmails = true;
newAccount.RelatedRecords = 'Contact';
System.debug('Inserting New Record'+newAccount);
insert newAccount;
// Send opportunity to IT instance
PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
newrecord.ConnectionId = cid;
newrecord.LocalRecordId = acId;
newrecord.SendClosedTasks = true;
newrecord.SendOpenTasks = true;
newrecord.SendEmails = true;
//newrecord.ParentRecordId = acc.AccountId;
System.debug('Inserting New Record'+newrecord);
insert newrecord;
}
}
Thanks
G.
}
}
Lead - gets converted to an Account , Contact and an Opportunity
I developed a trigger which shares an Opportunity and realted Account with another Org of ours, and the peice i am missing is sharing the Contact along with this . Need some help for sharing the contact also.
Trigger autoforwardOpportunity on Opportunity(after insert) {
String UserName = UserInfo.getName();
String orgName = UserInfo.getOrganizationName();
List<PartnerNetworkConnection> connMap = new List<PartnerNetworkConnection>(
[select Id, ConnectionStatus, ConnectionName from PartnerNetworkConnection where ConnectionStatus = 'Accepted']
);
System.debug('Size of connection map: '+connMap.size());
List<PartnerNetworkRecordConnection> prncList = new List<PartnerNetworkRecordConnection>();
for(Integer i =0; i< Trigger.size; i++) {
Opportunity acc = Trigger.new[i];
String acId = acc.Id;
System.debug('Value of OpportunityId: '+acId);
for(PartnerNetworkConnection network : connMap) {
String cid = network.Id;
String status = network.ConnectionStatus;
String connName = network.ConnectionName;
String AssignedBusinessUnit = acc.Assigned_Business_Unit__c;
System.debug('Connectin Details.......Cid:::'+cid+'Status:::'+Status+'ConnName:::'+connName+','+AssignedBusinessUnit);
if(AssignedBusinessUnit!=Null && (AssignedBusinessUnit.equalsIgnoreCase('IT') || AssignedBusinessUnit.equalsIgnoreCase('Proservia'))) {
// Send account to IT instance
PartnerNetworkRecordConnection newAccount = new PartnerNetworkRecordConnection();
newAccount.ConnectionId = cid;
newAccount.LocalRecordId = acc.AccountId;
newAccount.SendClosedTasks = true;
newAccount.SendOpenTasks = true;
newAccount.SendEmails = true;
newAccount.RelatedRecords = 'Contact';
System.debug('Inserting New Record'+newAccount);
insert newAccount;
// Send opportunity to IT instance
PartnerNetworkRecordConnection newrecord = new PartnerNetworkRecordConnection();
newrecord.ConnectionId = cid;
newrecord.LocalRecordId = acId;
newrecord.SendClosedTasks = true;
newrecord.SendOpenTasks = true;
newrecord.SendEmails = true;
//newrecord.ParentRecordId = acc.AccountId;
System.debug('Inserting New Record'+newrecord);
insert newrecord;
}
}
Thanks
G.
}
}
-
- goutham.tatineni1.3893010493585044E12
- February 24, 2014
- Like
- 1
Issue with Apex Save method while creating parent and Child record at same time
HI ,
I have a Parent Object (Client Site) and Child Object (Client Supplier ). What i am trying to acheive is i am trying to create 1 parent and multiple child records at the same time .Everything is working perfectly except I have one issue while i cretae a parent 1 Child record is created by deafult even if i do not want to .
I have a Parent Object (Client Site) and Child Object (Client Supplier ). What i am trying to acheive is i am trying to create 1 parent and multiple child records at the same time .Everything is working perfectly except I have one issue while i cretae a parent 1 Child record is created by deafult even if i do not want to .
public class AddClientSupplier { ApexPages.StandardController sc; public Client_Site__c acct{get;set;} public Integer marker=2; public Integer selectedClientSupplier{get;set;} public List<WrapperClass> lClientSuppliers{get;set;} public AddClientSupplier(ApexPages.StandardController controller) { this.acct = (Client_Site__c)controller.getRecord(); sc=controller; lClientSuppliers=new List<WrapperClass>(); Client_Supplier__c c=new Client_Supplier__c(); lClientSuppliers.add(new WrapperClass(c,1)); } public PageReference deleteClientSupplier(){ Integer x=-1; for(WrapperClass wc:lClientSuppliers){ x++; if(wc.counter==selectedClientSupplier){ System.debug('-->selected ClientSupplier:'+selectedClientSupplier+' position:'+x); break; } } lClientSuppliers.remove(x); return null; } public PageReference saveClientSite(){ Database.SaveResult sr = Database.insert(acct, false); Id idey=sr.getId(); List<Client_Supplier__c> ClientSupplierList=new List<Client_Supplier__c>(); for(WrapperClass wc:lClientSuppliers){ Client_Supplier__c c=new Client_Supplier__c(); c.Is_This_a_New_or_Incumbent_Supplier__c=wc.c.Is_This_a_New_or_Incumbe nt_Supplier__c; c.Skill_Type__c=wc.c.Skill_Type__c; c.Supplier_Name__c=wc.c.Supplier_Name__c; c.Will_Manpower_Manage_This_Supplier__c=wc.c.Will_Manpower_Manage_Thi s_Supplier__c; c.Client_Site__c=idey; ClientSupplierList.add(c); } insert ClientSupplierList; return(new PageReference('/'+sr.id).setRedirect(True)); } public PageReference addAClientSupplier(){ Client_Supplier__c c=new Client_Supplier__c(); lClientSuppliers.add(new WrapperClass(c,marker)); marker=marker+1; return null; } public class WrapperClass{ public Integer counter{get;set;} public Client_Supplier__c c{get;set;} public WrapperClass(Client_Supplier__c cntc,Integer i){ this.c=cntc; this.counter=i; } } }
<apex:page standardController="Client_Site__c" extensions="AddClientSupplier,ClientSiteExt" tabStyle="Client_Site__c"> <apex:form id="myForm" > <apex:sectionHeader title="New Client Site" /> <apex:pageBlock title=" Client Site Edit" mode="edit"> <apex:pageBlockButtons location="top" > <apex:commandButton value="Save" action="{!saveClientSite}" /> <apex:commandButton value="Cancel" action="{!Cancel}"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Information" columns="2"> <apex:inputField value="{!Client_Site__c.Client_Site_Name__c}" taborderhint="1"/> <apex:inputField value="{!Client_Site__c.Client_Discovery__c}" taborderhint="6"/> <apex:inputField value="{!Client_Site__c.City__c}" taborderhint="2"/> <apex:inputField value="{!Client_Site__c.Number_of_Shifts__c}" taborderhint="7"/> <apex:inputField value="{!Client_Site__c.State__c}" taborderhint="3"/> <apex:inputField value="{!Client_Site__c.Number_of_Team_Leads__c}" taborderhint="8"/> <apex:inputField value="{!Client_Site__c.Head_count__c}" taborderhint="4"/> <apex:inputField value="{!Client_Site__c.Number_of_On_Site_Managers__c}" taborderhint="9"/> <apex:inputField value="{!Client_Site__c.Job_Titles__c}" taborderhint="5"/> <apex:inputField value="{!Client_Site__c.Union_or_Non_Union__c}" taborderhint="10"/> </apex:pageBlockSection> <apex:pageBlockSection title="Client Suppliers" columns="4"> </apex:pageBlockSection> <apex:repeat value="{!lClientSuppliers}" var="x"> <apex:panelGrid columns="6"> <apex:panelGrid > <apex:facet name="header">Client Supplier Name</apex:facet> <apex:inputField value="{!x.c.Supplier_Name__c}" style="width:200px" /> </apex:panelGrid> <apex:panelGrid > <apex:facet name="header">Is This a New or Incumbent Supplier?y</apex:facet> <apex:inputField value="{!x.c.Is_This_a_New_or_Incumbent_Supplier__c}" style="width:200px" /> </apex:panelGrid> <apex:panelGrid > <apex:facet name="header">Skill Type</apex:facet> <apex:inputField value="{!x.c.Skill_Type__c}" style="width:200px"/> </apex:panelGrid> <apex:panelGrid > <apex:facet name="header"> Will Manpower manage this supplier?</apex:facet> <apex:inputField value="{!x.c.Will_Manpower_Manage_This_Supplier__c}" style="width:200px" /> </apex:panelGrid> <apex:panelGrid > </apex:panelGrid> <apex:commandButton action="{!deleteClientSupplier}" style="Button" value="Delete ClientSite" reRender="myForm" immediate="true"> <apex:param value="{!x.counter}" name="selected" assignTo="{!selectedContact}"/> </apex:commandButton> </apex:panelGrid> </apex:repeat> <apex:pageBlockButtons location="bottom"> <apex:panelGrid ></apex:panelGrid> <apex:commandButton value="Add Client Supplier" action="{!addAClientSupplier}" reRender="myForm" immediate="true" /> <apex:commandButton value="Save" action="{!saveClientSite}" /> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
- goutham.tatineni1.3893010493585044E12
- September 24, 2015
- Like
- 0
Old Test Class passes in UAT fails in Production
Hi Something strange happening all of a sudden .I am trying to deploy some code to proiduction and i am having 4 ols test classes failuers . All those classes were not modified recently nor any new validations or workfl;ows around them . Could some one help me out please
All my test classes are failing with same erorr System.QueryException: List has no rows for assignment to SObject
Same code in prod and sandbox since 2012 and not modifed since then.Here are the errors i get in production
System.QueryException: List has no rows for assignment to SObject (Same error For all the below methods)
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNOTNullAndTypeNOTNull: line 79, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNullAndTypeIsSentEmail: line 112, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNullAndTypeNOTNull: line 129, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.modifyMeetingTypeAndEventType: line 173, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.modifyOnlyEventType: line 200, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.modifyOnlyMeetingType: line 147, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNOTNullAndTypeIsNull: line 63, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNOTNullAndTypeIsSentEmail: line 95, column 1
All my test classes are failing with same erorr System.QueryException: List has no rows for assignment to SObject
@isTest private class TestUpdateEvents { private static Account acc{get;set;} private static User usr{get;set;} private static Profile p{get;set;} private static List<Event> EventsList{get;set;} /* Input: The standard type and Activity Type are passed in as parameters. Process: Inserts Event records. Output: 20 Events are created. Changes: */ static void createTestdata(String Eventtype, String MeetingType) { acc = new Account (name = 'TestUpdateEvents',phone='111111',BillingCity = 'TestUpdateEventsCity', BillingCountry ='TestUpdateEventsCountry', BillingStreet ='TestUpdateEventsStreet', BillingPostalCode ='updateEvent'); insert acc; p = [select id from profile where name='Sales Pro']; String[] environment = Userinfo.getUserName().split('@'); usr = new User(FirstName ='TestFirstName',Lastname= 'Testlastname',alias = 'Tst',email= 'TestFirstName1.Testlastname1@mpg.com', profileid = TestUpdateEvents.p.Id,username= 'TestFirstName'+ 'Testlastname'+'@'+environment[1],emailencodingkey='UTF-8', languagelocalekey='en_US',localesidkey='en_US',timezonesidkey='America/Los_Angeles', Country ='USA', CompanyName = 'Manpower',Brand__c = 'ManpowerGroup',Region__c = 'Corporate',Sub_Region__c = 'Corporate'); insert usr; EventsList = new List<Event>(); for(Integer i = 0; i < 20;i++) { Event e = new Event(); e.OwnerId = usr.Id; e.WhatId = acc.Id; e.Type = Eventtype; e.Meeting_Type__c = MeetingType; e.Subject='Test'+i; // t.Status = 'Not Started' ; // t.Priority = 'Normal' ; e.ActivityDate = Date.today() + 10; e.StartDateTime = Date.today() ; e.endDateTime = Date.today(); EventsList.add(e); } insert EventsList; } /* Input: No input variables Process: Insert Event records whose Type is null and Activity_Type is 'Call' Output: Validate the type field. It should be updated to Call Changes: None */ static testMethod void MeetingTypeNOTNullAndTypeIsNull() { createTestdata(null,'Call'); List<Event> insertedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< insertedEvents.size(); i ++) { System.assertEquals('Call', insertedEvents[i].Type); System.assertEquals('Call', insertedEvents[i].Meeting_Type__c); } } /* Input: No input variables Process: Insert Event records whose Type is 'Other' and Activity_Type is 'Call' Output: Validate the type field. It should be updated to Call Changes: None */ static testMethod void MeetingTypeNOTNullAndTypeNOTNull() { createTestdata('Other','Call'); List<Event> insertedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< insertedEvents.size(); i ++) { System.assertEquals('Call', insertedEvents[i].Type); System.assertEquals('Call', insertedEvents[i].Meeting_Type__c); } } /* Input: No input variables Process: Insert Event records whose Type is 'Sent E-mail' and Activity_Type is 'Call' Output: Validate the type and Activity_Type fields. Activity_Type should be updated to Sent E-mail. Changes: None */ static testMethod void MeetingTypeNOTNullAndTypeIsSentEmail() { createTestdata('Sent E-mail','Call'); List<Event> insertedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< insertedEvents.size(); i ++) { System.assertEquals('Sent E-mail', insertedEvents[i].Type); System.assertEquals('Sent E-mail', insertedEvents[i].Meeting_Type__c); } } /* Input: No input variables Process: Insert Event records whose Type is 'Sent E-mail' and Activity_Type is 'null' Output: Validate the Activity_Type field. It should be updated to Sent E-mail Changes: None */ static testMethod void MeetingTypeNullAndTypeIsSentEmail() { createTestdata('Sent E-mail',null); List<Event> insertedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< insertedEvents.size(); i ++) { System.assertEquals('Sent E-mail', insertedEvents[i].Type); System.assertEquals('Sent E-mail', insertedEvents[i].Meeting_Type__c); } } /* Input: No input variables Process: Insert Event records whose Type is 'Call' and Activity_Type is 'null' Output: Validate the type and Activity_Type fields. They should be updated to Call Changes: None */ static testMethod void MeetingTypeNullAndTypeNOTNull() { createTestdata('Call',null); List<Event> insertedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< insertedEvents.size(); i ++) { System.assertEquals('Call', insertedEvents[i].Type); System.assertEquals('Call', insertedEvents[i].Meeting_Type__c); } } /* Input: No input variables Process: Insert Event records whose Type is 'null' and Activity_Type is 'Call'. Then update the activity_Type from 'Call' to 'RFI' Output: Validate the type and Activity_Type fields. They should be updated to RFI. Changes: None */ static testMethod void modifyOnlyMeetingType() { createTestdata(null,'Call'); List<Event> updateEvents = new List<Event>(); updateEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< updateEvents.size(); i ++) { updateEvents[i].Meeting_Type__c = 'RFI'; } update updateEvents; List<Event> updatedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: updateEvents ORDER BY Id]; for(Integer i = 0;i< updatedEvents.size(); i ++) { System.assertEquals('RFI', updatedEvents[i].Type); System.assertEquals('RFI', updatedEvents[i].Meeting_Type__c); } } /* Input: No input variables Process: Insert Event records whose Type is 'null' and Activity_Type is 'Call'. Then update the activity_Type to 'Sent E-mail' and Type to 'Other' Output: Validate the type and Activity_Type fields. They should be updated to Sent E-mail. Changes: None */ static testMethod void modifyMeetingTypeAndEventType() { createTestdata(null,'Call'); List<Event> updateEvents = new List<Event>(); updateEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< updateEvents.size(); i ++) { updateEvents[i].Meeting_Type__c = 'Sent E-mail'; updateEvents[i].Type = 'Other'; } update updateEvents; List<Event> updatedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: updateEvents ORDER BY Id]; for(Integer i = 0;i< updatedEvents.size(); i ++) { System.assertEquals('Sent E-mail', updatedEvents[i].Type); System.assertEquals('Sent E-mail', updatedEvents[i].Meeting_Type__c); } } /* Input: No input variables Process: Insert Event records whose Type is 'null' and Activity_Type is 'Call'. Then update the standard Type to 'Sent E-mail' Output: Validate the type and Activity_Type fields. They should be updated to Sent E-mail. Changes: None */ static testMethod void modifyOnlyEventType() { createTestdata(null,'Call'); List<Event> updateEvents = new List<Event>(); updateEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: EventsList ORDER BY Id]; for(Integer i = 0;i< updateEvents.size(); i ++) updateEvents[i].Type = 'Sent E-mail'; update updateEvents; List<Event> updatedEvents = [SELECT Id,Meeting_Type__c,Type FROM Event WHERE Id in: updateEvents ORDER BY Id]; for(Integer i = 0;i< updatedEvents.size(); i ++) { System.assertEquals('Sent E-mail', updatedEvents[i].Type); System.assertEquals('Sent E-mail', updatedEvents[i].Meeting_Type__c); } } }
Same code in prod and sandbox since 2012 and not modifed since then.Here are the errors i get in production
System.QueryException: List has no rows for assignment to SObject (Same error For all the below methods)
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNOTNullAndTypeNOTNull: line 79, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNullAndTypeIsSentEmail: line 112, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNullAndTypeNOTNull: line 129, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.modifyMeetingTypeAndEventType: line 173, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.modifyOnlyEventType: line 200, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.modifyOnlyMeetingType: line 147, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNOTNullAndTypeIsNull: line 63, column 1
Class.TestUpdateEvents.createTestdata: line 27, column 1
Class.TestUpdateEvents.MeetingTypeNOTNullAndTypeIsSentEmail: line 95, column 1
- goutham.tatineni1.3893010493585044E12
- September 04, 2015
- Like
- 0
An error occurred when processing your submitted information when saving
<apex:page controller="CustomContactLookupController" title="Search" showHeader="false" sideBar="false" tabStyle="Contact" id="pg"> <apex:form > <apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;"> <apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel"> <!-- SEARCH TAB --> <apex:tab label="Contact Search" name="tab1" id="tabOne"> <apex:actionRegion > <apex:outputPanel id="top" layout="block" style="margin:1px;padding:10px;padding-top:2px;"> <apex:outputLabel value="{!$Label.OptyContRolePage_Search_Button}" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/> <apex:inputText id="txtSearch" value="{!searchString}"/> <span style="padding-left:5px"> <apex:commandButton id="btnGo" value="{!$Label.OptyContRolePage_Go_Button}" action="{!Search}" rerender="searchResults"> </apex:commandButton> </span> </apex:outputPanel> <apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;font-size:small" layout="block"> <apex:outputLabel value="{!$Label.OptyContRolePage_ResultSection}" style="font-weight:Bold;padding-right:10px;"/> <br/><br/> <apex:pageBlock id="searchResults" title="Contacts[{!searchContactCount}]"> <apex:pageBlockTable value="{!results}" var="a" id="tblResults"> <apex:column > <apex:facet name="header"> <apex:outputPanel >Name</apex:outputPanel> </apex:facet> <apex:outputLink value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!a.Name}',false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Name}</apex:outputLink> </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >Client Name</apex:outputPanel> </apex:facet> <apex:outputText value="{!a.Account.Name}" rendered="{!NOT(ISNULL(a.Id))}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >Phone</apex:outputPanel> </apex:facet> <apex:outputText value="{!a.Phone}" rendered="{!NOT(ISNULL(a.Id))}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >Email</apex:outputPanel> </apex:facet> <apex:outputText value="{!a.Email}" rendered="{!NOT(ISNULL(a.Id))}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:outputPanel> </apex:actionRegion> </apex:tab> <apex:tab label="New Contact" name="tab2" id="tabTwo"> <apex:pageBlock id="newContact" title="New Contact"> <apex:pageBlockButtons > <apex:commandButton action="{!SaveContact}" value="Save"/> </apex:pageBlockButtons> <apex:pageMessages /> <apex:pageBlockSection columns="2"> <apex:repeat value="{!$ObjectType.Contact.FieldSets.CustomContactLookup}" var="f"> <apex:inputField value="{!Contact[f]}"/> </apex:repeat> <!-- <apex:inputField value="{!Contact.LastName}"/> <apex:inputField value="{!Contact.Email}"/> <apex:inputField value="{!Contact.AccountID}"/> --> </apex:pageBlockSection> </apex:pageBlock> </apex:tab> </apex:tabPanel> </apex:outputPanel> </apex:form> </apex:page>
public with sharing class CustomContactLookupController { public Contact Contact {get;set;} // new Contact to create public List<Contact> results{get;set;} // search results public string searchString{get;set;} // search keyword public Id ultiAccId; public Id localAccId; public Integer searchContactCount {get;set;} public CustomContactLookupController() { // get the current search string searchString = System.currentPageReference().getParameters().get('lksrch'); ultiAccId = System.currentPageReference().getParameters().get('ultimateAccId'); localAccId= System.currentPageReference().getParameters().get('localAccId'); runSearch(); } // performs the keyword search public PageReference search() { searchContactCount = 0; runSearch(); return null; } // prepare the query and issue the search command private void runSearch() { // TODO prepare query string for complex serarches & prevent injections results = performSearch(searchString); } // run the search and return the records found. private List<Contact> performSearch(string searchString) { //String[] tokens; //String accIds; List<Account> SudsidaryAccounts = [select Id from Account where Ultimate_Parent_Client__c =:ultiAccId and id!=null limit 10000]; List<String> accIds = new List<String>(); accIds.add(ultiAccId); for(Account acc : SudsidaryAccounts) { accIds.add(acc.Id); } List<contact> conts = [select id, name,AccountId,Email,Phone,Account.Name from Contact where Name LIKE: '%'+searchString +'%' and AccountId IN: accIds]; searchContactCount = conts.size(); return conts; } // save the new Contact record public PageReference saveContact() { insert Contact; // reset the Contact Contact = new Contact(); return null; } // used by the visualforce page to send the link to the right dom element public string getFormTag() { return System.currentPageReference().getParameters().get('frm'); } // used by the visualforce page to send the link to the right dom element for the text box public string getTextBox() { return System.currentPageReference().getParameters().get('txt'); } }
When i save the record in a LookUp , This weird error comes up. Any idea why this is happening.
- goutham.tatineni1.3893010493585044E12
- April 06, 2015
- Like
- 0
Error on VF ( An error occurred when processing your submitted information)
pg:j_id0:newContact:j_id52:j_id53:0:j_id54: An error occurred when processing your submitted information.
Hi,
I have a VF page for a Custom lookup and when i save the record a weird error is showing up . Any help please, after much research i found this happens sometimes due to Space issues and i already corrected all the Spaces and still i have the issue.
Hi,
I have a VF page for a Custom lookup and when i save the record a weird error is showing up . Any help please, after much research i found this happens sometimes due to Space issues and i already corrected all the Spaces and still i have the issue.
<apex:page controller="CustomContactLookupController" title="Search" showHeader="false" sideBar="false" tabStyle="Contact" id="pg"> <apex:form > <apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;"> <apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel"> <!-- SEARCH TAB --> <apex:tab label="Contact Search" name="tab1" id="tabOne"> <apex:actionRegion > <apex:outputPanel id="top" layout="block" style="margin:1px;padding:10px;padding-top:2px;"> <apex:outputLabel value="{!$Label.OptyContRolePage_Search_Button}" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/> <apex:inputText id="txtSearch" value="{!searchString}"/> <span style="padding-left:5px"> <apex:commandButton id="btnGo" value="{!$Label.OptyContRolePage_Go_Button}" action="{!Search}" rerender="searchResults"> </apex:commandButton> </span> </apex:outputPanel> <apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;font-size:small" layout="block"> <apex:outputLabel value="{!$Label.OptyContRolePage_ResultSection}" style="font-weight:Bold;padding-right:10px;"/> <br/><br/> <apex:pageBlock id="searchResults" title="Contacts[{!searchContactCount}]"> <apex:pageBlockTable value="{!results}" var="a" id="tblResults"> <apex:column > <apex:facet name="header"> <apex:outputPanel >Name</apex:outputPanel> </apex:facet> <apex:outputLink value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!a.Name}',false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Name}</apex:outputLink> </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >Client Name</apex:outputPanel> </apex:facet> <apex:outputText value="{!a.Account.Name}" rendered="{!NOT(ISNULL(a.Id))}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >Phone</apex:outputPanel> </apex:facet> <apex:outputText value="{!a.Phone}" rendered="{!NOT(ISNULL(a.Id))}"/> </apex:column> <apex:column > <apex:facet name="header"> <apex:outputPanel >Email</apex:outputPanel> </apex:facet> <apex:outputText value="{!a.Email}" rendered="{!NOT(ISNULL(a.Id))}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:outputPanel> </apex:actionRegion> </apex:tab> <apex:tab label="New Contact" name="tab2" id="tabTwo"> <apex:pageBlock id="newContact" title="New Contact"> <apex:pageBlockButtons > <apex:commandButton action="{!saveContact}" value="Save"/> </apex:pageBlockButtons> <apex:pageMessages /> <apex:pageBlockSection columns="2"> <apex:repeat value="{!$ObjectType.Contact.FieldSets.CustomContactLookup}" var="f"> <apex:inputField value="{!Contact[f]}"/> </apex:repeat> </apex:pageBlockSection> </apex:pageBlock> </apex:tab> </apex:tabPanel> </apex:outputPanel> </apex:form> </apex:page>
public with sharing class CustomContactLookupController { public Contact Contact {get;set;} // new Contact to create public List<Contact> results{get;set;} // search results public string searchString{get;set;} // search keyword public Id ultiAccId; public Id localAccId; public Integer searchContactCount {get;set;} public CustomContactLookupController() { // get the current search string searchString = System.currentPageReference().getParameters().get('lksrch'); ultiAccId = System.currentPageReference().getParameters().get('ultimateAccId'); localAccId= System.currentPageReference().getParameters().get('localAccId'); runSearch(); } // performs the keyword search public PageReference search() { searchContactCount = 0; runSearch(); return null; } // prepare the query and issue the search command private void runSearch() { // TODO prepare query string for complex serarches & prevent injections results = performSearch(searchString); } // run the search and return the records found. private List<Contact> performSearch(string searchString) { //String[] tokens; //String accIds; List<Account> SudsidaryAccounts = [select Id from Account where Ultimate_Parent_Client__c =:ultiAccId and id!=null limit 10000]; List<String> accIds = new List<String>(); accIds.add(ultiAccId); for(Account acc : SudsidaryAccounts) { accIds.add(acc.Id); } List<contact> conts = [select id, name,AccountId,Email,Phone,Account.Name from Contact where Name LIKE: '%'+searchString +'%' and AccountId IN: accIds]; searchContactCount = conts.size(); return conts; } // save the new Contact record public PageReference saveContact() { insert Contact; // reset the Contact Contact = new Contact(); return null; } // used by the visualforce page to send the link to the right dom element public string getFormTag() { return System.currentPageReference().getParameters().get('frm'); } // used by the visualforce page to send the link to the right dom element for the text box public string getTextBox() { return System.currentPageReference().getParameters().get('txt'); } }
- SF7
- March 16, 2015
- Like
- 0
Help With Test class for Batch Apex on Opportunity Line Item
System.UnexpectedException: No more than one executeBatch can be called from within a testmethod. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation.
@isTest(seeAllData=true) private class TestConversionRate { @isTest static void MyUnitTest() { // Set up some local variables String opportunityName = 'My Opportunity'; String standardPriceBookId = ''; PriceBook2 pb2Standard = [select Id from Pricebook2 where isStandard=true]; standardPriceBookId = pb2Standard.Id; Account a = new Account(Name = 'Berlington'); Insert a; // set up opp and Verify that the results are as expected. Opportunity o = new Opportunity(AccountId = a.id, Name=opportunityName, StageName='Discovery', CloseDate=Date.today()); insert o; Opportunity opp = [SELECT Name FROM Opportunity WHERE Id = :o.Id]; //System.assertEquals(opportunityName, 'Berlington - 0 -'); // set up product2 and Verify that the results are as expected. Product2 p2 = new Product2(Name='Test Product',isActive=true); insert p2; Product2 p2ex = [SELECT Name FROM Product2 WHERE Id = :p2.Id]; //System.assertEquals('Test Product', p2ex.Name); // set up PricebookEntry and Verify that the results are as expected. PricebookEntry pbe = new PricebookEntry(Pricebook2Id=standardPriceBookId, Product2Id=p2.Id, UnitPrice=99, isActive=true); insert pbe; PricebookEntry pbeex = [SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbe.Id]; //System.assertEquals(standardPriceBookId, pbeex.Pricebook2Id); Win_Rate__c w = new Win_Rate__c(Name = 'Manpower - Brazil - 121-180',Win_rate__c = 90 ); Insert W; // set up OpportunityLineItem and Verify that the results are as expected. OpportunityLineItem oli = new OpportunityLineItem(PriceBookEntryId=pbe.Id, OpportunityId=o.Id,WinRate__c = w.id,Hidden_Name__c = w.name, Quantity=1, TotalPrice=99); insert oli; OpportunityLineItem oliex = [SELECT PriceBookEntryId FROM OpportunityLineItem WHERE Id = :oli.Id]; System.assertEquals(pbe.Id, oliex.PriceBookEntryId); opportunityLineItem Oppl = [Select Id,Name ,WinRate__c ,Hidden_Name__c from OpportunityLineItem where id =:oli.id]; system.assertnotEquals(oppl.WinRate__c ,''); } static testMethod void BatchProcessAccount_TestMethod (){ Test.StartTest(); UpdateWinRateBatch objBatch = new UpdateWinRateBatch(); ID batchprocessid = Database.executeBatch(objBatch); Test.StopTest(); } }
- goutham.tatineni1.3893010493585044E12
- July 24, 2014
- Like
- 0