How to filter through records using bean factory

Hello Sugar Developer Community 

I am having difficulties accomplishing the following 

-- Entrypoint ::  create leads 

JSON is sent over and the creation of the lead is underway 

I am passed a value that would represent a company name to place into a company name relate field. 

Problem: 

Cannot add relate without the ID 

-- Trying to get the ID by name 

$sql = new SugarQuery();
$accBean = BeanFactory::getBean("Accounts");
$sql->select('id');
$sql->from($accBean);
$nameAC = $vars->architectComp;     *** is an account name
$sql->where()->contains('name', $nameAC);
$result = $sql->execute();
$bean->account_id_c = $result[0]['id'];      //When replaced with an existing ID string . -- write successful 

I always get an empty result .     -- from what i gather my $accBean is empty because i have supplied no ID 

Please help me understand how to load the accounts and itereate through them to get an ID if the name is a match. 

** Would like to use the current recommended sugar standards as of 8.0 but if it has to be "hacky" i can work with that !

Thank you 

  • Hi David Matrai 

    I would recommend you to convert your entryPoint into an endpoint once entryPoints will be deprecated in future release.

    The result is empty probably because you called the entryPoint without authentication.

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hey André

    Thank you 

    That makes perfect sense and explains why i do not have any data pulled