function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rahul Sangwan7341Rahul Sangwan7341 

System.DmlException: Process failed. First exception on row 0; first error: MANAGER_NOT_DEFINED, Manager undefined.: []

u=[Select Id,ManagerId from User where UserName='abc@gmail.com'];
        System.debug('.....User...........'+u+'........'+u.ManagerId);
        List<Credit_Enhancement__c> creditList=creditListTestData();
        creditList[0].OwnerId=u.Id;
		test.startTest();

		insert creditList; 

		creditList[0].DummySentForApproval__c=true;


		creditList[0].DummyApprovedCB__c=true;
		System.runAs(u){
		Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
        req1.setComments('Submitting request for approval.');
        req1.setObjectId(creditList[0].id);
        req1.setSubmitterId(u.Id);
        Approval.ProcessResult result = Approval.process(req1);
    	}

		update creditList;
SaranSaran
Hi Rahul,

The user record does not have managerId. The Query at line no 1 - for the user u the manager id field is null so you are getting this error.

Solution:-
Create another test user and assign that test user as the manager for the user u.

Thanks,
Saraz
Rahul Sangwan7341Rahul Sangwan7341
I have checked this is not coming as null. I am getting value in ManagerId.