Hi everyone,
i am building an external application interacting with the SuiteCRM using REST API. I have created a module “franchise” which would have many leads in it, so created a one to many relationship between franchise and leads. Now i am trying retrieve a lead record and the franchise associated to it. But I get an empty result. Here’s my code:
$get_franchise_lead_parameters = array(
‘session’=>$sessionID,
‘module_name’=>‘Leads’,
‘module_id’=>$_GET[‘leadid’], //the id of the specific lead record.
‘link_field_name’=>‘wbur_franchise_leads_1’,
‘related_fields’=>array(
‘id’,
‘name’,
),
‘deleted’ => ‘0’,
);
$get_franchise_lead = call(‘get_relationships’,$get_franchise_lead_parameters, $url);
But this not coorect, when i login to the suite crm, i can see the franchise name linked to each lead created.
I also tried using the get_entry_list method to retrieve all the Leads and tried to retrieve the field wbur_franchise_leads_1_name and assigned_user_name. I could get assigned_user_name but not the franchise name. Why is this so? When assigned_user_name is also relationship field why dont I get wbur_franchise_leads_1_name?
What you have looks reasonable, there’s a few things you can try however.
Try replacing $_GET with a hardcoded Lead id so you can test that it isn’t due to this (is $_GET in the code you are using? This is unlikely to be an id - it is the array of GET parameters).
Secondly you can check the link name - ensure that it is wbur_franchise_leads_1. Note that this is not the relationship name but the name of the link field on leads.
Thanks for this!
Is there any easy method to just get all the related modules for all the records using get_entry_list method, rather than giving an id and then retriving the related record?
As far as I’m aware there’s no way to get all the related modules without specifying. I think you’ll need to specify each relationship you want to retrieve using the link_name_to_fields_array parameter of get_entry_list.