Reference field shows value as 'undefined'

AnotherNOWDev
Tera Expert

Hello,

I'm currently working on a 'after- insert' Business Rule that initializes a new record using current values, but some are sending an 'undefined' value even though they are full.

All values being managed are from reference fields

For example we have this two fields in the current form.

- Area Desarrollo (u_area_desarrollo)

- Clasificación del Proyecto (u_clasificacion_del_proyecto)

Now.. after they insert that record the business rule triggers and this is the code

// This is the part of the code where the mistake appears

var gr = new GlideRecord('pm_project');

gr.initialize();

gr.u_area_desarrollo = current.u_area_desarrollo;

gr.u_clasificacion_del_proyecto = current.u_clasificacion_del_proyecto;

gr.insert();

After the Business Rule runs, this is how the new record's form shows. You can see that 'Clasificación del Proyecto' got filled, while 'Area Desarrollo' stayed empty.

When I displayed the values in a string, 'Clasificación del Proyecto' brings the sys_id of the reference (as planned) and 'Area Desarrollo' displays a value of 'undefined'. Why is this happening? Any ideas?

If you need any more information please let me know