Multiple Flex Relate Fields in a form

Has anyone managed to create multiple Flex Relate Fields in a form?

I got round the issue by adding the fields to vardefs

'activity_type' => array (
						'name' => 'activity_type',
						'vname' => 'LBL_ACTIVITY_NAME',
						'type' => 'parent_type',
						'dbType' => 'varchar',
						'group' => 'activity_name',
						'required' => false,
						'reportable' => false,
						'len' => '25',
						'comment' => 'The Sugar object to which the call is related' 
				),
				
				'activity_name' => array (
						'name' => 'activity_name',
						'activity_type' => 'record_type_display',
						'type_name' => 'activity_type',
						'id_name' => 'activity_id',
						'vname' => 'LBL_ACTIVITY',
						'type' => 'parent',
						'group' => 'activity_name',
						'source' => 'non-db',
						'options' => 'zz_exp_activity_type',
						'required' => true,
						'studio' => 'visible' 
				),
				
				'activity_id' => array (
						'required' => true,
						'name' => 'activity_id',
						'type' => 'id',
						'group' => 'activity_name',
						'reportable' => false,
						'vname' => 'LBL_ACTIVITY_ID',
						'studio' => 'visible',
				),
				

It then works properly in EdiView but not in DetailView

I added the following to view.details.php to fix the issue:

//activity
		if ($this->bean->activity_id){
			$a = new $this->bean->activity_type;
			$a->Retrieve($this->bean->activity_id);
			$this->bean->activity_name = $a->name;
		}

Has anyone got a better solution?

Hi,

Is there a way to do this with a normal relate field as opposed to a FlexRelate?

Thanks

What is your issue?

You can have as many relate fields in a form as you want with no issues

Thanks for your reply.

I’m going to create a module with a list of spare parts, I need to be able to attach these part numbers to a Support Ticket, some customers might need more than one part, so having a field with plus and minus buttons appeals.

I currently have an ExtendedPhone Field with DropDowns in it, this ensures clean data as it stops people typing which parts they want in adhoc ways.

I’ve decided a multiple relate field with a qty alongside it might be a best practice.