AnsweredAssumed Answered

Non accessible quotes getting loaded by bean

Question asked by Sagar Honrao on Feb 13, 2019

I want to load quotes by user role access and permission.Using SugarQuery and Bean object ,I am trying to load the quotes but I am getting non-accessible quotes in the result. Please suggest me any way to get user accessible Quotes only.Here in my case, user has meeting's account access but account's quotes dose not have user access. 

The following approach I have used.

$meeting_bean = BeanFactory::getBean("Meetings",$meeting_id);

$acc_bean = BeanFactory::getBean('Accounts', $meeting_bean->parent_id);



//using sugarQuery

   $get_quotes = new SugarQuery();
   $get_quotes->from(BeanFactory::newBean('Quotes'), array('alias' => 'q'));
   $get_quotes->joinTable('quotes_cstm', array('alias' => 'qc'))->on()->equalsField('', 'qc.id_c');
   $get_quotes->joinTable('quotes_accounts', array('alias' => 'qa'))->on()->equalsField('', 'qa.quote_id')->equals('qa.deleted', 0);
   $get_quotes->where()->equals('qa.account_id', $acc_bean->id);
   $get_quotes->where()->equals('q.deleted', 0);
   $get_quotes->where()->equals('qa.account_role', "Bill To");
   $quote_order = $get_quotes->execute();




//using Bean object

$q = $acc_bean->quotes->get();

foreach($q as $key=>$val){
   $bean = BeanFactory::getBean('Quotes',$val);
   $c[] = $bean ->name;