Civirules api action exception: Unable to remove/add tags.
1 unresolved thread
Merge request reports
Activity
mentioned in issue #15 (closed)
47 47 //alter parameters by subclass 48 48 $params = $this->alterApiParameters($params, $triggerData); 49 49 50 // check if record already exists in db. 51 try { 52 $id = civicrm_api3('EntityTag', 'getvalue', $params + ['return' => 'id']); 53 if (strtolower($action) == 'create') { 54 continue; 55 } 56 } 57 catch (CiviCRM_API3_Exception $e) { 58 if (strtolower($action) == 'delete') { 59 continue; Use case:
Action -> Delete:
- Check if a contact is already tagged.
- If yes then api will return id and contact will be removed from tag
- If No api will throw exception and will go into catch part and it will skip the foreach loop and move to next as we don't need to perform delete since the contact is not tagged
Action -> Add
- Check if a contact is already tagged.
- If yes then api will return id and then it will go in if statement, So we don't need to add contact to tag which has been already tagged so skip the foreach loop and move to next.
- If No api will throw exception and will go into catch part and won't go in if statement since action is create so it will create entry entity tag table.
EntityTag api throws exception when you try to perform delete action when contact is not tagged. This PR solves the problem as it checks before sending it to CiviCRM api.
mentioned in commit 26b28d66
Thanks @pradeep
Please register or sign in to reply