
EnvioDeCorreoTest ActaTest System.DmlException: Insert failed. First exception on row 0; 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.EnvioDeCorreoTest.InsertAccount: line 12, column 1 Class.EnvioDeCorreoTest.ActaTest: line 146, column 1
EnvioDeCorreoTest Admisiontest System.DmlException: Insert failed. First exception on row 0; 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.EnvioDeCorreoTest.InsertAccount: line 12, column 1 Class.EnvioDeCorreoTest.Admisiontest: line 36, column 1
EnvioDeCorreoTest Intencionesestudiotest System.DmlException: Insert failed. First exception on row 0; 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.EnvioDeCorreoTest.InsertAccount: line 12, column 1 Class.EnvioDeCorreoTest.Intencionesestudiotest: line 54, column 1
EnvioDeCorreoTest Matriculaciontest System.DmlException: Insert failed. First exception on row 0; 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.EnvioDeCorreoTest.InsertAccount: line 12, column 1 Class.EnvioDeCorreoTest.Matriculaciontest: line 98, column 1
EnvioDeCorreoTest Preinscripciontest System.DmlException: Insert failed. First exception on row 0; 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.EnvioDeCorreoTest.InsertAccount: line 12, column 1 Class.EnvioDeCorreoTest.Preinscripciontest: line 73, column 1
EnvioDeCorreoTest Titulotest System.DmlException: Insert failed. First exception on row 0; 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.EnvioDeCorreoTest.InsertAccount: line 12, column 1 Class.EnvioDeCorreoTest.Titulotest: line 122, column 1
My code has the following Method:
public static void InsertAccount() {
Id recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Alumnos').getRecordTypeId();
account = new Account(Name = 'Test Account', PersonEmail = 'testaccount@test.com', Nacionalidad__c = 'España', Tipo_de_Id__c = 'DNI', DNI__c = '12345678', RecordTypeId = recordTypeId);
insert account;
}
What it does is to insert a new account with record type "Alumnos" (Students).
My test class EnviodeCorreoTest looks like this:
What I don't understand is, where is the issue. The error is pointing to the field "Name" of the object Account, so far I understand. If I am executing the deployment as Admin, I have access to this field. In the method Admisiontest() I am calling the InsertAccount() method.All error lines are also pointing to the line:InsertAccount();Can please somebody help me to find the answer?. I am stuck in this issue and can not deploy to Production :(.@isTest(SeeAllData=true)
private class EnvioDeCorreoTest {
static Preinscripci_n__c preinscripcion;
static Product2 postgrado;
static Account account;
public static void InsertAccount() {
Id recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Alumnos').getRecordTypeId();
account = new Account(Name = 'Test Account', PersonEmail = 'testaccount@test.com', Nacionalidad__c = 'España', Tipo_de_Id__c = 'DNI', DNI__c = '12345678', RecordTypeId = recordTypeId);
insert account;
}
@isTest
static void Admisiontest() {
InsertAccount();
InsertPostgrado();
InsertContacto();
Admisi_n__c admision = new Admisi_n__c();
admision.Nombre_de_la_cuenta__c = account.Id;
admision.Idioma_de_preferencia__c = 'Español';
admision.Programa_Acad_mico__c = postgrado.Id;
insert admision;
Test.startTest();
EnvioDeCorreo.enviarCorreoAdmision(admision, 'Notificaci_n_de_registro_de_Admision');
Test.stopTest();
}
...
the rest of the methods for enrollments, pre-enrollments, etc. look similar

Alex, I could solve my problem! :). I have amended the line:
so that it looks now so:public static void InsertAccount() {
Id recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Alumnos').getRecordTypeId();
account = new Account(Name = 'Test Account', PersonEmail = 'testaccount@test.com', Nacionalidad__c = 'España', Tipo_de_Id__c = 'DNI', DNI__c = '12345678', RecordTypeId = recordTypeId);
insert account;
}
public static void InsertAccount() {
Id recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Alumnos').getRecordTypeId();
account = new Account(FirstName = 'Test', LastName = 'Test', PersonEmail = 'testaccount@test.com', Nacionalidad__c = 'España', Tipo_de_Id__c = 'DNI', DNI__c = '12345678', RecordTypeId = recordTypeId);
insert account;
}
It probably says that there is no access to the Name field because if you insert an account you have to first indicate first name and last name for the first time, giving this information the field Name can be filled.
I also removed the part with the InsertContact() in my code according to this thread:https://salesforce.stackexchange.com/questions/7747/invalid-cross-reference-key-can-not-select-a-person-account-accountidSo, I could then deploy the test class.Thank so much anyway for your efforts.