You need to sign in to do that
Don't have an account?
Ignacio Jimenez
Help undestanding NULL values here.
Hello, I am testing a Trigger which calculates and fill a few custom fields (type currency), then saves in local variables the values calcutated by the trigger. After that I modify a few fields so the trigger executes again, to finally compare old values with the new ones. The assert lines fail because of null values are equal.
This code is in the test class:
//Create the object
Cotizacion__c coti = new Cotizacion__c();
coti.Propuesta__c = p.Id;
coti.Descuento__c = 0;
coti.CurrencyIsoCode = 'CLF';
insert coti;
System.debug('Coti Name: '+ coti);
//Create a child object which is modified later
Linea_CotizacionNom__c l1 = new Linea_CotizacionNom__c();
l1.Cotizacion__c = coti.Id;
l1.Rol__c = 'L1';
l1.Tipo_Asignacion__c = 'HH';
l1.Cargo_del_Rol__c = 'Director de Proyectos';
l1.Dedicacion__c = 25;
l1.Meses__c= 4;
insert l1;
//Guardar valores antes del cambio para comparar.
//SAves locally old values before update.
double tarifaSugerida = l1.Tarifa_Sugerida_v2__c;
double CostoRolV2 = l1.Costo_Rol_v2__c;
double CostoTmP= l1.Costo_Linea_Nomina_tmp__c;
double CostoLineaNomina = l1.Costo_Linea_Nomina__c;
System.debug(LoggingLevel.INFO, '[TEST] ---MODIFICA LINEA]');
l1.Tipo_Asignacion__c = 'Mes';
l1.Rol__c= 'L2';
l1.Cargo_del_Rol__c = 'Gerente de Proyectos';
l1.Dedicacion__c = 50;
l1.Meses__c= 3;
update l1;
System.debug(LoggingLevel.INFO, '[TEST] ---MODIFICA LINEA: GRABADO --> VALORES NUEVOS]');
System.debug(LoggingLevel.INFO, '[TEST] L1 Modif:]'+ l1);
//comparo si han cambiado los campos calculados.
System.assertNotEquals(l1.Tarifa_Sugerida_v2__c,tarifaSugerida);
System.assertNotEquals(l1.Costo_Rol_v2__c,CostoRolV2);
System.assertNotEquals(l1.Costo_Linea_Nomina_tmp__c,CostoTmP);
System.assertNotEquals(l1.Costo_Linea_Nomina__c,CostoLineaNomina);
The weird thing is after saving the object, I do get an ID, but the Name field logs a NULL value.
Name is a an auto numbered field.
Questions:
1. Does anyone can see why I am getting null values in the Name of object l1 ?
2. How can I do some debug with breakpoint as I used tod do before the Interactive Apex Debugger was released? I use Eclipse.
Ignacio
Thanks you!
This code is in the test class:
//Create the object
Cotizacion__c coti = new Cotizacion__c();
coti.Propuesta__c = p.Id;
coti.Descuento__c = 0;
coti.CurrencyIsoCode = 'CLF';
insert coti;
System.debug('Coti Name: '+ coti);
//Create a child object which is modified later
Linea_CotizacionNom__c l1 = new Linea_CotizacionNom__c();
l1.Cotizacion__c = coti.Id;
l1.Rol__c = 'L1';
l1.Tipo_Asignacion__c = 'HH';
l1.Cargo_del_Rol__c = 'Director de Proyectos';
l1.Dedicacion__c = 25;
l1.Meses__c= 4;
insert l1;
//Guardar valores antes del cambio para comparar.
//SAves locally old values before update.
double tarifaSugerida = l1.Tarifa_Sugerida_v2__c;
double CostoRolV2 = l1.Costo_Rol_v2__c;
double CostoTmP= l1.Costo_Linea_Nomina_tmp__c;
double CostoLineaNomina = l1.Costo_Linea_Nomina__c;
System.debug(LoggingLevel.INFO, '[TEST] ---MODIFICA LINEA]');
l1.Tipo_Asignacion__c = 'Mes';
l1.Rol__c= 'L2';
l1.Cargo_del_Rol__c = 'Gerente de Proyectos';
l1.Dedicacion__c = 50;
l1.Meses__c= 3;
update l1;
System.debug(LoggingLevel.INFO, '[TEST] ---MODIFICA LINEA: GRABADO --> VALORES NUEVOS]');
System.debug(LoggingLevel.INFO, '[TEST] L1 Modif:]'+ l1);
//comparo si han cambiado los campos calculados.
System.assertNotEquals(l1.Tarifa_Sugerida_v2__c,tarifaSugerida);
System.assertNotEquals(l1.Costo_Rol_v2__c,CostoRolV2);
System.assertNotEquals(l1.Costo_Linea_Nomina_tmp__c,CostoTmP);
System.assertNotEquals(l1.Costo_Linea_Nomina__c,CostoLineaNomina);
The weird thing is after saving the object, I do get an ID, but the Name field logs a NULL value.
Name is a an auto numbered field.
Questions:
1. Does anyone can see why I am getting null values in the Name of object l1 ?
2. How can I do some debug with breakpoint as I used tod do before the Interactive Apex Debugger was released? I use Eclipse.
Ignacio
Thanks you!
Name is auto number field it will be created only when you will insert record.
and to access Name field which is Auto number you have to use SOQL.
write this code after insert l1.
Best Regards,
Amit Ghadage.
All Answers
Name is auto number field it will be created only when you will insert record.
and to access Name field which is Auto number you have to use SOQL.
write this code after insert l1.
Best Regards,
Amit Ghadage.