Body: <p>When a certain event is created with CiviEvent, I have a Civirule creating a related activity. I need to grab the name of the event to use it as the subject of the activity. By default it would be empty or fixed.</p>
  <p>Where would you start coding?</p>
  <p><a href="https://i.sstatic.net/6j3gh.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/6j3gh.png" alt="CiviRule" /></a></p>
  <p>EDIT 1: we are adding a new 'Add Action' following <a href="https://docs.civicrm.org/civirules/en/latest/create-your-own-action/" rel="nofollow noreferrer">this guide</a></p>
  <p>EDIT 2: I know the action is triggered when adding an event so their must be a way to get the variable of the event_id so I can use APIv3 and get the event_title.</p>
  <p>I tested to echo variables in the subject field but it doesn't quite work.</p>
  <p>I searched on APIv3 in order to have the event_title but I need the event id.</p>
  <pre><code>if (!empty($data['subject'])) {
    $return = '';
    $params = $this-&gt;getActionParameters();
    $defaultValues['subject'] = civicrm_api3('Event', 'getvalue', [
    'return' =&gt; 'title',
    'id' =&gt; $params['event_id']]);
  $return .= ts(&quot;Subject: %1&quot;, [1 =&gt; $subject]);
  return $return;
  }
  </code></pre>
  <p>What should we improve?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-25T20:39:32.317Z
Comments.Text: do you mean 'event' as in a CiviEvent? just aware the term 'event' has multiple uses
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-28T07:41:06.647Z
Comments.Text: yes the title of the event from CiviEVENT.
Comments.UserDisplayName: Guillaume Sorel
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-29T14:06:57.593Z
Comments.Text: When you say echoing the variables doesn't work, not sure what you mean. If you want to see the whole params array use something like var_export($params, true). You can also output that to the civi log with CRM_Core_Error::debug_log_message().
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-29T16:09:06.660Z
Comments.Text: I'm working on uploads/civicrm/ext/org.civicoop.civirules/CRM/CivirulesActions/Activity.php
  
  
   echo var_export($params, true) result in NULL maybe this explain why my echo didn't work but the file is still using variables
  
  
  CRM_Core_Error::debug_log_message() don't log anything in my console.
Comments.UserDisplayName: Anatole Allain
Tags: <civirules>
Title: Get event name FROM CiviEvent in activity subject
ThreadText: # Get event name FROM CiviEvent in activity subject
  
  (Asked by: username_0 on 2021-06-25)
  
  When a certain event is created with CiviEvent, I have a Civirule creating a related activity. I need to grab the name of the event to use it as the subject of the activity. By default it would be empty or fixed.
  
  Where would you start coding?
  
  [![CiviRule](https://i.sstatic.net/6j3gh.png)](https://i.sstatic.net/6j3gh.png)
  
  EDIT 1: we are adding a new 'Add Action' following [this guide](https://docs.civicrm.org/civirules/en/latest/create-your-own-action/)
  
  EDIT 2: I know the action is triggered when adding an event so their must be a way to get the variable of the event\_id so I can use APIv3 and get the event\_title.
  
  I tested to echo variables in the subject field but it doesn't quite work.
  
  I searched on APIv3 in order to have the event\_title but I need the event id.
  
  ```
  if (!empty($data['subject'])) {
    $return = '';
    $params = $this->getActionParameters();
    $defaultValues['subject'] = civicrm_api3('Event', 'getvalue', [
    'return' => 'title',
    'id' => $params['event_id']]);
  $return .= ts("Subject: %1", [1 => $subject]);
  return $return;
  }
  
  ```
  
  What should we improve?
  
  **Tags:** civirules
  
  > **Comments:**
  > **username_1**: do you mean 'event' as in a CiviEvent? just aware the term 'event' has multiple uses  
  > **username_0**: yes the title of the event from CiviEVENT.  
  > **username_2**: When you say echoing the variables doesn't work, not sure what you mean. If you want to see the whole params array use something like var_export($params, true). You can also output that to the civi log with CRM_Core_Error::debug_log_message().  
  > **username_3**: I'm working on uploads/civicrm/ext/org.civicoop.civirules/CRM/CivirulesActions/Activity.php    echo var_export($params, true) result in NULL maybe this explain why my echo didn't work but the file is still using variables   CRM_Core_Error::debug_log_message() don't log anything in my console.  
  
  ---
  
  ## 0 answers
  
  