Answers.Body: <p>I have identified the problem.</p>
  <p>This occurred only for the activities where the activity participant wasn't set. So it's all about contact record type in the civicrm_activity_contact table. The issue happens when you load the activity where you don't have the target specified (record_type_id = 3). If this happens the activity data loads, but the custom fields data don't.
  I don't know if this is expected behavior, but I don't think so.</p>
  <p>For me the fix is easy, I will just write an SQL query that will add the target contact (which same as the activity creator in my case).</p>
  <p>I will create the issue for Drupal Webform CiviCRM Integration module.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-28T23:01:27.487Z
Answers.LastActivityDate: 2020-06-28T23:01:27.487Z
Answers.UserDisplayName: Marko
Body: <p>When I setup a webform to update existing activities, and I give it cid and activity1 parameters in the URL, the webform loads up contact information and core activity information, but not the custom fields data. The custom fields just stay blank.</p>
  <p>My first instinct was to re-examine the permissions, but this is the administrator account (with all Drupal permissions checked), additionally I added the Civicrm ACL permission to view/edit the custom field (not that this should matter) but the issue persists. I can add activities and custom data just fine, display the data using Views, but custom field data just doesn't load up in the webform, it's blank.</p>
  <p>How would I go about debugging this? Am I missing something obvious?</p>
  <p>I tried to recreate the issue on another instance with the same version of Civi and Drupal, but I couldn't do it, everything just works there.</p>
  <p>Civicrm 5.20.0 | Drupal 7.72 (modules up to date) | PHP 7.1.33</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-26T21:42:41.440Z
Comments.Text: why not give an example of your url - might need to be aid1= not activity1= (perhaps both work)
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-26T21:43:35.703Z
Comments.Text: what entity are the custom fields on?
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-26T21:44:41.323Z
Comments.Text: oh i see you say that core Activity fields load but not the custom ones. sounds odd.
Comments.UserDisplayName: petednz - fuzion
Tags: <drupal><webform-civicrm><activities><permissions>
Title: Custom Fields for Activities not getting Prefilled by a Drupal Webform
ThreadText: # Custom Fields for Activities not getting Prefilled by a Drupal Webform
  
  (Asked by: username_0 on 2020-06-26)
  
  When I setup a webform to update existing activities, and I give it cid and activity1 parameters in the URL, the webform loads up contact information and core activity information, but not the custom fields data. The custom fields just stay blank.
  
  My first instinct was to re-examine the permissions, but this is the administrator account (with all Drupal permissions checked), additionally I added the Civicrm ACL permission to view/edit the custom field (not that this should matter) but the issue persists. I can add activities and custom data just fine, display the data using Views, but custom field data just doesn't load up in the webform, it's blank.
  
  How would I go about debugging this? Am I missing something obvious?
  
  I tried to recreate the issue on another instance with the same version of Civi and Drupal, but I couldn't do it, everything just works there.
  
  Civicrm 5.20.0 | Drupal 7.72 (modules up to date) | PHP 7.1.33
  
  **Tags:** drupal, webform-civicrm, activities, permissions
  
  > **Comments:**
  > **username_1**: why not give an example of your url - might need to be aid1= not activity1= (perhaps both work)  
  > **username_1**: what entity are the custom fields on?  
  > **username_1**: oh i see you say that core Activity fields load but not the custom ones. sounds odd.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-06-28. Score: 1 | Accepted answer
  
  I have identified the problem.
  
  This occurred only for the activities where the activity participant wasn't set. So it's all about contact record type in the civicrm\_activity\_contact table. The issue happens when you load the activity where you don't have the target specified (record\_type\_id = 3). If this happens the activity data loads, but the custom fields data don't.
  I don't know if this is expected behavior, but I don't think so.
  
  For me the fix is easy, I will just write an SQL query that will add the target contact (which same as the activity creator in my case).
  
  I will create the issue for Drupal Webform CiviCRM Integration module.
  
  
  ---
  
  