You need to sign in to do that
Don't have an account?
Connor Small 5
This controller works for a VF page I have that renders other pages if they meet criteria.
This Controller also achieves for the same purpose
This Test Class (for the second controller) achieves 7/8 coverage in Sandbox but fails deployment because of error below
"System.DmlException: Update failed. First exception on row 0 with id 0012E00002KmF35QAF; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.: [Name]
Stack Trace: Class.MyPageController.Save: line 13, column 1 Class.MyPageControllerTest.testMethodMyController: line 20, column 1"
Anyone have any insight as to how to test Controller 1 or improve test for controller 2 so as not to fail deployment for that reason?
Test Class for Controller that only Queries Record
public class MyController { public Account account { get; set; } public MyController() { account = [SELECT Id, Name, Billing_Tier__c, Primary_Contact_Full_Name__C,Secondary_Contact_Full_Name__c,One_Line_Address__c FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; } }
This controller works for a VF page I have that renders other pages if they meet criteria.
This Controller also achieves for the same purpose
public class MyPageController { Public final Account account; public MyPageController() { account = [SELECT Id, Name, Billing_Tier__c, Primary_Contact_Full_Name__C,Secondary_Contact_Full_Name__c,One_Line_Address__c FROM Account WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; } public Account getAccount() { return account; } public PageReference Save(){ Update account; Return Null; } }
This Test Class (for the second controller) achieves 7/8 coverage in Sandbox but fails deployment because of error below
"System.DmlException: Update failed. First exception on row 0 with id 0012E00002KmF35QAF; first error: INVALID_FIELD_FOR_INSERT_UPDATE, Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.: [Name]
Stack Trace: Class.MyPageController.Save: line 13, column 1 Class.MyPageControllerTest.testMethodMyController: line 20, column 1"
Anyone have any insight as to how to test Controller 1 or improve test for controller 2 so as not to fail deployment for that reason?
This appears to be an access issue on the Name field for the user running in the test context. I recommend checking the following
Query on UserFieldAccess
Obtain the Id of the user who is running in the test context (You can find the id from the debug logs) and execute the following queries (Note: These are sample queries)
Use the unique DurableId returned above to query UserFieldAccess.
Replace Account Name with OwnerId or any other field that you want to check the access for
Let me know if this helps
Anudeep