S
S
Sergey Ch2017-12-27 14:37:13
1C-Bitrix
Sergey Ch, 2017-12-27 14:37:13

Why does the Fetch() method in an arbitrary php code of the Bitrix24 business process not return false?

Why does the Fetch() method in an arbitrary php code of the Bitrix24 business process not return false?
The same method, if used not in a Business process, but simply in a php file, works as it should - if there is no data, it returns false.

$rootActivity = $this -> GetRootActivity();
$em = $rootActivity->GetVariable("EMAIL_WORK"); 

$rs = CCrmFieldMulti::GetList(
  array(),
  array(
  'ENTITY_ID' => 'LEAD',
  'VALUE' =>$em ,	
  'COMPLEX_ID' => 'EMAIL_WORK' 
  )
    );

  
  if ($rs->Fetch()) {
  
              $rootActivity->SetVariable("isDubleCQ",1); 

              }  else {
 $rootActivity->SetVariable("isDubleCQ",0); 
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2017-12-27
@elov4anin

It seems to me that the problem is not in the fetch method. The main question is what is in the $em variable at the time the elements are found.
You know that if $em = true, it's the same as $em = 1, but if $em = false it won't find anything.
After assigning $em, add the following code:

ob_start();
echo "<pre>";
var_dump( array(
  'ENTITY_ID' => 'LEAD',
  'VALUE' =>$em , 
  'COMPLEX_ID' => 'EMAIL_WORK' 
));
file_put_contents($_SERVER['DOCUMENT_ROOT'].'/test_bp_val.txt', ob_get_clean(), FILE_APPEND);

And understand why it returns a particular value

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question