You need to sign in to do that
Don't have an account?
maman
MyProfilePageController Apex test failure
We are getting an error when running a test on the MyProfilePageController Apex class, as follows:
System.DmlException: Insert failed.
First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, A first name is required.[Full_Name__c]
Stack Trace Class.MyProfilePageController.testSave: line 93, column 1
Since Apex tests are run when deploying change sets, we cannot deploy a set until this error is resolved. Problem is, we didn't write the code, and we're not developers. Looks like it's Salesforce.com code. Unfortunately, we don't have Premium support, and Salesforce will not assist and have directed us to this forum.
Help!
System.DmlException: Insert failed.
First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, A first name is required.[Full_Name__c]
Stack Trace Class.MyProfilePageController.testSave: line 93, column 1
Since Apex tests are run when deploying change sets, we cannot deploy a set until this error is resolved. Problem is, we didn't write the code, and we're not developers. Looks like it's Salesforce.com code. Unfortunately, we don't have Premium support, and Salesforce will not assist and have directed us to this forum.
Help!
From the looks of it you introduced a validation rule that broke the unit test provided by Salesforce. Therefore, you'll need to address it by modifying the testSave method in your MyProfilePageController. Looking at what I have in my org (also auto generated by Salesforce), I would try updating lines 91 - 93 from
To:
If Full_Name__c is a text field, this should work. If it's a formula field, then you would need to set the fields that are used by that formula instead.
Hope that helps.
:
All Answers
Also, you are in for a world of hurt if you don't have any developers on your team and are running into Apex issues. If you haven't already, your team should check out Trailhead for a primer on Apex and development: https://developer.salesforce.com/en/trailhead/. Additionally, I suggest you look into bringing someone onto your team, either a FT employee, contractor, or consultant that understands Apex and Salesforce development.
Comments from the code:
/** * An apex class that keeps updates of a portal user in sync with its corresponding contact. Guest users are never able to access this page. */
Dependent components are a ChangePassword Visualforce page and controller called ChangePasswordController.
Let me reiterate that we didn't write this code or its dependant components, so it's not our test method. How can we determine the author of this code?
If it is Salesforce.com code, don't other orgs have this problem? Or, did we inadvertantly break this code in our org with the installation of a third-party app?
From the looks of it you introduced a validation rule that broke the unit test provided by Salesforce. Therefore, you'll need to address it by modifying the testSave method in your MyProfilePageController. Looking at what I have in my org (also auto generated by Salesforce), I would try updating lines 91 - 93 from
To:
If Full_Name__c is a text field, this should work. If it's a formula field, then you would need to set the fields that are used by that formula instead.
Hope that helps.
:
Since we wanted to keep the first name required, we hacked around and figured out how to modify the class in the sandbox and uploaded a new version to the live org. Solution was:
91 Contact c = new Contact();
92 c.LastName = 'Contact';
92 c.FirstName = 'Test';
93 insert c;
Frustrating that we could innocently break Salesforce code in this way using out-of-the-box tools, then be unable to get Basic support.