Prepopulate Name text field in subpanel

Hello,
i have one moduleA related to moduleB so moduleB is also present in subpanel.

I would like during quickCreate a way to autocomplete name field with parent module name appendinh after something like -001

so for example one record in moduleA could be PO0001 then every records in subpanel could be autofilled like so:
PO0001-001
PO0001-002
PO0001-003
abd so on…

any hint to achieve it?
extending viewedit?
fieldsto namearray?
or what?

Thank you

Copy the file /suitecrm/modules/your_module/your_module.php to /suitecrm/custom/modules/your_module/

Edit it and add the next code

function fill_in_additional_detail_fields()
{
	parent::fill_in_additional_detail_fields();
	if (@$_REQUEST['target_action'] == "QuickCreate")
	{
		$opp_id = @$_REQUEST['opportunity_id'];
		if ($opp_id != "")
		{
			$opp = new Opportunity();
			$opp->retrieve($opp_id);
			$this->accounts_custom_module_1_name        = $opp->account_name; //the account name gets copied
			$this->accounts_custom_module_1accounts_ida = $opp->account_id; //the account id gets copied
			$this->users_custom_module_1_name           = $opp->assigned_user_name; //the user name gets copied
			$this->users_custom_module_1users_ida       = $opp->assigned_user_id; //the user id get copied
		}
	}
}

in this example I’m passing the Account and Assigned user to my related custom module from Opportunities module, give it a try and let me know

remember to repair and rebuild after and always test it in a test environment

best regards

mmm…its sounds cool…but not clear this part:

$opp_id = @$_REQUEST[‘opportunity_id’];

What is this [opportunity_id]?

Which database field or vardef is? i need to change it based on my custom module…but also based on my opportunities module i cannot find anything related

Can u explain me well this part?

Thank you

With your browser make an inspect element or view source code, depending on your browser, and check the id’s of the fields in your parent and child module

Best regards

just to clarify
Parent Module = DBGIT_Items
Subpanel = DBGIT_AirfreightLoads

Based on your explanation this could me my code:

function fill_in_additional_detail_fields()
{
parent::fill_in_additional_detail_fields();
if (@$_REQUEST[‘target_action’] == “QuickCreate”)
{
$item_id = $_REQUEST[‘id’];
if ($item_id != “”)
{
$item = new DBGIT_AirFreightLoads();
$item->retrieve($item_id);
$this->name = “TEST”;
}
}
}

This should be the problem:
$item_id = $_REQUEST[‘id’];
if ($item_id != “”)
it never cheks because if i commented out this it works…

i just need to understand better how to map and retrieve my intended field

Thanks

maybe i’ve found…
i could use:
$item_id = $_REQUEST[‘parent_id’];

is it correct?

Thank you for pointing me on the right direction

Thanks

done:

function fill_in_additional_detail_fields()
{
parent::fill_in_additional_detail_fields();
if (@$_REQUEST[‘target_action’] == “QuickCreate”)
{
$item_id = $_REQUEST[‘parent_name’];
if ($item_id != “”)
{
$item = new DBGIT_AirFreightLoads();
$item->retrieve($item_id);
$this->name = $item_id;
}
}
}

Thanks

What about use the same way to assigned the same user_id from the parent to teh related one?

Is there any better way to do that?

Thanks