• RayaP
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi all,

I am struggling since hours trying to find out what the root cause is and how to solve it, but til now without success.

I am trying to deploy a test class.
Here the following relationship: Account has a master detail relationship with Admissions (Admisiones), Study Interests (Intenciones de Estudio), Enrollments (Matriculaciones), Pre-enrollments (Preinscripciones) and Actas.

When trying to deploy the test class, I am getting these errors:
 
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:
 
@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

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 :(.