Answers.Body: <p>Can you try changing the type of the element to <code>computed_twig</code> and confirm if it stores the subject correctly?</p>
  <p>The source yaml could look like:</p>
  <pre><code>  civicrm_1_activity_1_activity_subject:
      '#type': computed_twig
      '#title': 'Activity Subject'
      '#prepopulate': true
      '#template': '{{ uuid }} - {{ data.civicrm_2_contact_1_contact_existing }} - {{ data.civicrm_2_contact_1_contact_external_identifier }}'
      '#store': true
      '#form_key': civicrm_1_activity_1_activity_subject
      '#extra':
        width: 20
      '#parent': civicrm_1_activity_1_fieldset_fieldset
  </code></pre>
  <p>The above snippet assumes you have <code>Existing Contact</code> enabled for 2nd contact in your webform settings.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-26T14:33:02.217Z
Answers.LastActivityDate: 2024-02-26T14:33:02.217Z
Answers.UserDisplayName: jitendra - fuzion
Body: <p>I am testing a proof of concept for photo uploads.  I want the name of each photo to have a unique ID with a combination of the Organisation's External ID, its CiviCRM contact ID, and a random number. The Organisation is selected on the form via an auto complete and its name displayed, and its External ID and Contact ID are stored via two Hidden fields.  This all works fine.</p>
  <p>I can rename the files on submission by using the 'rename files' and the following tokens:</p>
  <pre><code>[webform_submission:values:civicrm_2_contact_1_contact_contact_id]-[webform_submission:values:civicrm_2_contact_1_contact_external_identifier]-[webform_submission:uuid]
  </code></pre>
  <p>Each file gets stored with the unique prefix with an _1, _2 etc and so this also works as expected.</p>
  <p>It then goes awry with CiviCRM activities.  I have a CiviCRM activity attached to this form and want the Activity subject to have the same unique number.  I have used exactly the same tokens but the only one that prints is <code>[webform_submission:uuid]</code>?  I cannot get the contact ID <code>[webform_submission:values:civicrm_2_contact_1_contact_contact_id]</code> or External ID <code>[webform_submission:values:civicrm_2_contact_1_contact_external_identifier]</code> to store in the subject line.  Exactly the same tokens will print fine in a confirmation screen or email.  I end up with a subject of the two raw tokens and the correct UUID.</p>
  <p>I have tried them individually (as the help says use commas to separate default values), but again, the only one that works is the UUID.</p>
  <p>Any ideas?</p>
  
Tags: <webform-civicrm><tokens>
Title: Webform token works for file name pattern but not for activity subject?
ThreadText: # Webform token works for file name pattern but not for activity subject?
  
  (Asked by: username_0 on 2024-02-14)
  
  I am testing a proof of concept for photo uploads. I want the name of each photo to have a unique ID with a combination of the Organisation's External ID, its CiviCRM contact ID, and a random number. The Organisation is selected on the form via an auto complete and its name displayed, and its External ID and Contact ID are stored via two Hidden fields. This all works fine.
  
  I can rename the files on submission by using the 'rename files' and the following tokens:
  
  ```
  [webform_submission:values:civicrm_2_contact_1_contact_contact_id]-[webform_submission:values:civicrm_2_contact_1_contact_external_identifier]-[webform_submission:uuid]
  
  ```
  
  Each file gets stored with the unique prefix with an \_1, \_2 etc and so this also works as expected.
  
  It then goes awry with CiviCRM activities. I have a CiviCRM activity attached to this form and want the Activity subject to have the same unique number. I have used exactly the same tokens but the only one that prints is `[webform_submission:uuid]`? I cannot get the contact ID `[webform_submission:values:civicrm_2_contact_1_contact_contact_id]` or External ID `[webform_submission:values:civicrm_2_contact_1_contact_external_identifier]` to store in the subject line. Exactly the same tokens will print fine in a confirmation screen or email. I end up with a subject of the two raw tokens and the correct UUID.
  
  I have tried them individually (as the help says use commas to separate default values), but again, the only one that works is the UUID.
  
  Any ideas?
  
  **Tags:** webform-civicrm, tokens
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-02-26. Score: 1
  
  Can you try changing the type of the element to `computed_twig` and confirm if it stores the subject correctly?
  
  The source yaml could look like:
  
  ```
    civicrm_1_activity_1_activity_subject:
      '#type': computed_twig
      '#title': 'Activity Subject'
      '#prepopulate': true
      '#template': '{{ uuid }} - {{ data.civicrm_2_contact_1_contact_existing }} - {{ data.civicrm_2_contact_1_contact_external_identifier }}'
      '#store': true
      '#form_key': civicrm_1_activity_1_activity_subject
      '#extra':
        width: 20
      '#parent': civicrm_1_activity_1_fieldset_fieldset
  
  ```
  
  The above snippet assumes you have `Existing Contact` enabled for 2nd contact in your webform settings.
  
  
  ---
  
  