You need to sign in to do that
Don't have an account?
Harjeet Singh 28
System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: [] test class
Hi All,
I have been stuck in test class and not getting a way to solve the issue.Upon running the test class I am getting error :System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
Below is the CONTROLLER snippets:
Below is my test clas:
Kindly help
Many thanks in advance
I have been stuck in test class and not getting a way to solve the issue.Upon running the test class I am getting error :System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
Below is the CONTROLLER snippets:
public class SurveyForDriverController{ //class variables public Driver_Survey__c survey{get;set;} public String newSurveyList {get;set;} public String newSurveyListSecond {get;set;} public String newSurveyListThird {get;set;} public String newSurveyListFourth {get;set;} public String newSurveyListFifth {get;set;} public SurveyForDriverController(ApexPages.StandardController controller){ system.debug('message3>>****'+ApexPages.currentPage().getParameters().get('recordID') ); if (ApexPages.currentPage().getParameters().get('recordID') !=null) survey = [SELECT Id, Name__c, Mobile__c, Email__c, from Driver_Survey__c where id = :ApexPages.currentPage().getParameters().get('recordID') ]; else survey=new Grab_Driver_Survey__c(); } public PageReference doFullSave(){ survey.Customer_Experience__c=newSurveyList; insert survey; PageReference pageRef = new PageReference('/'+survey.Id); pageRef.setRedirect(true); return pageRef; } public PageReference saveRecord( ) { survey.Customer_Experience__c=newSurveyList; update survey; return Page.DriverSurveyThankyouVF; } public void doCancel(){ PageReference pageRef = new PageReference('/'); pageRef.setRedirect(true); } }
Below is my test clas:
@isTest public class TestSurveyForDriverController { static testMethod void testForSalesforceUsers () { Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; Driver_Survey__c driverSurvey=new Driver_Survey__c(); ApexPages.StandardController ctlr = new ApexPages.StandardController(driverSurvey); SurveyForDriverController grabController=new SurveyForDriverController(ctlr); Test.startTest(); grabController.survey.Customer_Experience__c='6'; grabController.survey.Email__c='test@test.com'; grabController.survey.Expected_Earnings_Weekly__c=10000; grabController.survey.Name='testuser1'; grabController.survey.Name__c='testuser1'; grabController.doFullSave(); grabController.doCancel(); Test.stopTest(); } static testMethod void testForExternalUsers () { Profile p = [SELECT Id FROM Profile WHERE Name='Transport Questionnaire Profile']; Driver_Survey__c driverSurvey=new Driver_Survey__c(); ApexPages.StandardController ctlr = new ApexPages.StandardController(driverSurvey); SurveyForDriverController grabController=new SurveyForDriverController(ctlr); Test.startTest(); driverSurvey.Name='testuser1'; driverSurvey.Name__c='testuser1'; driverSurvey.Email__c='emailuser@testorg.com'; Driver_Survey__c driverSurvey1=new Driver_Survey__c(); ApexPages.StandardController ctlr1 = new ApexPages.StandardController(driverSurvey1); SurveyForDriverController grabController1=new SurveyForDriverController(ctlr1); driverSurvey1.Name__c='testuser2'; driverSurvey1.Email__c='emailuser@testorg.com'; driverSurvey1.Id=driverSurvey.id; update driverSurvey1; grabController.saveRecord(); Test.stopTest(); } }
Kindly help
Many thanks in advance
I got the solution for the above error. Actually I was not passing id to the update record so the error was coming.I checked my debug logs and solved it accordingly.
Below is the code snippet which I used to pass the record id
I hope it will help someone if face same issue
Many thanks in advance