I’m building a custom module in which I have a custom drop-down (fetches the Account List from the db). The module has Generate Letter functionality as I need to generate PDF out it. But when the PDF template is parsed, the variable for the custom drop-down shows the drop-down id instead of the value.
I traced it down to the data object retrieved by the retrieve method in the SugarBean class. The data object contains the ID of the custom dropdown fetched from the custom module table. Instead of this ID I need the value of the custom dropdown. How do I go about doing that?
I solution I’ve configured so far is:
Extend the retrieve method from the SugarBean class in the custom_module class (i.e; in //modules/custom_module/custom_module.php)
Overwrite the query executed by the default retrieve method in the custom_module class and include the dropdown value instead of ID
But the retrieve method executes a lot of functions before returning the generated data object. How do I replicate it ?
Or is this a very complex solution which I’ve designed so far and there can be another simpler approach to it?
With not much progress on it, I directly created a SugarBean object in the custom class and passed the record id with $_REQUEST[‘record’] to the retrieve method.
It’s getting the record id alright but not getting the table name from which to query the id. I do not want to change the default functioning of the retrieve method.
I have created a custom module with a custom dropdown. But the custom dropdown if used somewhere else fetches the record ids instead of the values, so I need to modify Suite’s default retrieve method so that I get the dropdown’s values as well.
But it’s not advisable to modify the default retrieve method for obvious reasons.
Hence I extended it in the module_class but now the query doesn’t get the table name.
while calling that dropdown in other palce there only some error is there i think. can you show me that code where you are calling that custom dropdown code.
if(! empty($_REQUEST['id'])){
$id = $_REQUEST['id'];
$proposal = new p_proposal(); // this is my custom module class name
$proposal->retrieve($id);
$account_id = $proposal->accounts_p_proposal_1accounts_ida;
$account_name = $proposal->accounts_p_proposal_1_name;
}
see this way i can get the values whatever i need.
first time while creating time this will return null value, beceause there is no value in record.
while editing time it will work . beceause that time record id will be present . so put one condition before that whether empty or not. i think for the first time its getting empty value so only some error is producing. try to do like this and check.
if(! empty($_REQUEST['record'])){
$id = $_REQUEST['record'];
$custom_module = new custom_module(); // this is my custom module class name
$custom_module->retrieve($id);
}
No it’s not empty. Whenever you load a record there’s always a ‘record’ in the URL. Anyway thanks Jaydeep for all the time and help. I guess I will have to carve out another solution for this or will have to check if there are any code updates in this. Will get back to you once this is done or if I face another hitch
Btw which version of Suite are you customizing it in ?