Custom field get NULL when edit and save

Hi,

I created a new custom field on AOS_LINE_ITEM_GROUPS module and it was instalked with manifest.php (on Suite / Admin / Load Module). Created OK!

Then, this field is updated via another application (update on data base).

But I have a problem.

When I edit a record on SuiteCRM (Quote or Contracts) this custom filed got NULL.

Is there any way to avoid this, keeping the data in the field, without making it null?

It looks like your vardefs aren’t correctly configured, so the link between the database and the PHP code isn’t working.

Did you do a “Quick Repair and Rebuild” after creating the field?

In that repair, did you scroll down all the way, to see if it required you to run an SQL command, and clicked to do it?

Does your field show the current value in the database, and then turns NULL when you edit it, or does it never show any value at all?

Hi, following the anwers for your consideration.

It looks like your vardefs aren’t correctly configured, so the link between the database and the PHP code isn’t working.

The vardefs was define throgh “Module Loader” with “manifest.php” file. Here the configuration into this file:

<?php
    $manifest =array(
		  0 => 
		  array (
			'acceptable_sugar_versions' => 
			array (
			  0 => '',
			),
		  ),
		  1 => 
		  array (
			'acceptable_sugar_flavors' => 
			array (
			  0 => 'CE',
			  1 => 'PRO',
			  2 => 'ENT',
			),
		  ),
        'author' => 'SCS',
        'description' => 'Installs a custom fields to the aos_line_item_groups',
        'icon' => '',
        'is_uninstallable' => true,
        'name' => 'Line Item Groups - Custom Fields',
        'published_date' => '2016-03-14 20:45:04',
        'type' => 'module',
        'version' => 1,
    ); 	
	
    $installdefs =array(
        'id' => 'AOS_Line_Item_Groups_Custom_Fields_1',
        'language'=> array (
			array(
				'from'=> '<basepath>/Files/Language/AOS_Line_Item_Groups/pt_br.lang.php',
				'to_module'=> 'AOS_Quotes',
				'language'=>'pt_br'
			),	
		),
		'custom_fields'=>array (
			//Numero Contrato
		    array(
		        'name' => 'numctr_c',
		        'label' => 'LBL__NUMCTR',
		        'type' => 'int',
		        'module' => 'AOS_Line_Item_Groups',
		        'help' => '',
		        'comment' => '',
		        'default_value' => '',
		        'max_size' => 9,
		        'required' => false, // true or false
		        'reportable' => true, // true or false
		        'audited' => false, // true or false
		        'importable' => 'true', // 'true', 'false', 'required'
		        'duplicate_merge' => false, // true or false
				'ext1' => '', 
				'ext2' => '',
				'ext3' => '',
				'ext4' => '',
			),
		),
    );

Vardefs created on …/custom/modules/AOS_Line_Item_Groups/Ext/Vardefs :

<?php 
 // created: 2016-04-12 15:32:40
$dictionary['AOS_Line_Item_Groups']['fields']['numctr_c']['inline_edit']=0;
$dictionary['AOS_Line_Item_Groups']['fields']['numctr_c']['duplicate_merge_dom_value']=0;
?>

Did you do a “Quick Repair and Rebuild” after creating the field?
Yes, I did a “Quick Repair and Rebuild” after creating the field.

In that repair, did you scroll down all the way, to see if it required you to run an SQL command, and clicked to do it?
I scroll down all the way, but I did not see SQL command running requeried.

Does your field show the current value in the database, and then turns NULL when you edit it, or does it never show any value at all?
This field is update via database directly (without SuiteCRM) throwgh another application, then while the record it is not edited on SuiteCRM, the data stay on database in the field. It turn NULL, just after edit the record on SuiteCRM.
An important information: this custom field does not appear on screen (layout) the SuiteCRM. Also it does not appear on Admin / Studio, because the AOS_Line_Item_Groups module is not visible there.

I am not familiar with changing the modules through the manifest file, so I can only give you some lateral advice here…

Those $dictionary entries don’t look very complete to me, shouldn’t they be more like this?:

$dictionary['<module>']['fields']['name'] => array (
    'name' => 'name',
    'vname' => 'LBL_NAME',
    'dbType' => 'varchar',
    'type' => 'name',
    'len' => '50',
    'comment' => 'Example Vardef',
    'required' => false,
    'unified_search' => true,
    'full_text_search' => array('boost' => 3),
);

It could be worthwhile investigating if the values get read correctly from the database, into the beans. Maybe you could put up a field to show that on a detail screen somewhere. Just so you know if the problem is when reading, or when writing the edited record.