Answers.Body: <p>If I'm understanding correctly, all you need to do is make an extension and call <code>CRM_Core_Resources::singleton()-&gt;addStyle()</code> in hook_buildForm as described at <a href="https://docs.civicrm.org/dev/en/latest/framework/resources/#css-stylesheets" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/framework/resources/#css-stylesheets</a> since activities with priority urgent already get class priority-urgent added to the <code>&lt;tr&gt;</code> element in the table that lists the activities.</p>
  <p>e.g.
  <code>CRM_Core_Resources::singleton()-&gt;addStyle('#crm-container table.nestedActivitySelector tr.priority-urgent {background-color: orange;}');</code></p>
  <p>The <code>#crm-container table.nestedActivitySelector</code> part is required because otherwise the more specific css target from core gets applied instead.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-08T09:39:43.540Z
Answers.Text: Can you tell me where exactly activities with priority urgent get the class priority-urgent added to the <tr> element? And where does the more specific css target from core get applied?
Answers.UserDisplayName: emma
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-08T14:53:32.053Z
Answers.Text: `grep -r priority-urgent *` - says it's in CRM/Case/BAO/Case.php - line 1022 (I'm using 5.31/dev - line number might be slightly different in other versions.) Similarly the more specific css part is in css/civicrm.css.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-07T15:41:05.213Z
Answers.LastActivityDate: 2020-10-07T15:46:29.630Z
Answers.LastEditDate: 2020-10-07T15:46:29.630Z
Answers.UserDisplayName: Demerit
Body: <p>In the CiviCRM system I work on, activities created for a specific case can have the priority &quot;normal&quot; or &quot;urgent&quot;. This attribute is set by the user when creating the activity inside the CaseView. Internally, the &quot;priority_id&quot; of this activity is set to 1 == &quot;urgent&quot; or 2 == &quot;normal&quot;.
  Now, I want to mark the activities with priority &quot;urgent&quot; in another color when listed in the CaseView as well as in the Case Overview (Cases &gt; My Cases). I started with the first task (changing the activity layout in the CaseView activity list).</p>
  <p>I tried modifying the sites/all/modules/civicrm/templates/CRM/Case/Form/ActivityToCase.tpl at line 23, added the following if-clause. This template is included in sites/all/modules/civicrm/templates/CRM/Case/Form/CaseView.tpl in line 259, which seemed like the correct place in the CaseView.tpl for the activities to appear. I added:</p>
  <pre><code>{if $form.priority_id == 1}
     &lt;td class=&quot;label urgent&quot;&gt;{$form.file_on_case_activity_subject.label}&lt;/td&gt;
  {elseif $form.priority_id == 2}
     &lt;td class=&quot;label&quot;&gt;{$form.file_on_case_activity_subject.label}&lt;/td&gt;
  {/if}
  </code></pre>
  <p>where before we only had:</p>
  <pre><code>&lt;td class=&quot;label&quot;&gt;{$form.file_on_case_activity_subject.label}&lt;/td&gt;
  </code></pre>
  <p>When this didn't work, I tried to set an &quot;urgent&quot; class to the $form.file_on_case_activity_subject.html as well:</p>
  <pre><code>{if $form.priority_id == 1}
            &lt;td class=&quot;label urgent&quot;&gt;{$form.file_on_case_activity_subject.label}&lt;/td&gt;
            &lt;td class=&quot;urgent&quot;&gt;{$form.file_on_case_activity_subject.html}&lt;br /&gt;
              &lt;span class=&quot;description&quot;&gt;{ts}You can modify the activity subject before filing.{/ts}&lt;/span&gt;
            &lt;/td&gt;
          {elseif $form.priority_id == 2}
          &lt;td class=&quot;label&quot;&gt;{$form.file_on_case_activity_subject.label}&lt;/td&gt;
            &lt;td&gt;{$form.file_on_case_activity_subject.html}&lt;br /&gt;
              &lt;span class=&quot;description&quot;&gt;{ts}You can modify the activity subject before filing.{/ts}&lt;/span&gt;
            &lt;/td&gt;
          {/if}
  </code></pre>
  <p>where before we only had:</p>
  <pre><code>&lt;td class=&quot;label&quot;&gt;{$form.file_on_case_activity_subject.label}&lt;/td&gt;
  &lt;td&gt;{$form.file_on_case_activity_subject.html}&lt;br /&gt;
              &lt;span class=&quot;description&quot;&gt;{ts}You can modify the activity subject before filing.{/ts}&lt;/span&gt;
            &lt;/td&gt;
  </code></pre>
  <p>As this didn't work either, I suppose I am modifying the wrong place. Any hint anyone?</p>
  <p>Edit: I created an extension with the following code, but it doesn't work yet:</p>
  <pre><code>function mark_urgent_activities_civicrm_buildForm($formName, &amp;$form) {
    if ($formName == 'CRM_Case_Form_CaseView') {
      CRM_Core_Resources::singleton()-&gt;addStyle('#crm-container table.nestedActivitySelector tr.priority-urgent {background-color: orange;}');
    }
  }
  </code></pre>
  <p>Edit2: Accessing the elements with priority-urgent class works in the css file, both as</p>
  <pre><code>.priority-urgent {
  font-weight: bold;
  }
  </code></pre>
  <p>and</p>
  <pre><code>#crm-container table.nestedActivitySelector tr.priority-urgent {
  font-weight: bold;
  }
  </code></pre>
  <p>The (background / font) color doesn't work yet, but I suppose that's only because  element cannot have background color.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-08T14:51:19.940Z
Comments.Text: It worked when I tested it - but I didn't restrict to CRM_Case_Form_CaseView. The table is created by magic after the page loads so maybe there's a timing issue if you restrict the form. The background-color worked for me - maybe you have other customizations conflicting?
Comments.UserDisplayName: Demerit
Tags: <civicase><activity>
Title: Marking Activities with Priority "urgent" in another color
ThreadText: # Marking Activities with Priority "urgent" in another color
  
  (Asked by: username_0 on 2020-10-07)
  
  In the CiviCRM system I work on, activities created for a specific case can have the priority "normal" or "urgent". This attribute is set by the user when creating the activity inside the CaseView. Internally, the "priority_id" of this activity is set to 1 == "urgent" or 2 == "normal".
  Now, I want to mark the activities with priority "urgent" in another color when listed in the CaseView as well as in the Case Overview (Cases > My Cases). I started with the first task (changing the activity layout in the CaseView activity list).
  I tried modifying the sites/all/modules/civicrm/templates/CRM/Case/Form/ActivityToCase.tpl at line 23, added the following if-clause. This template is included in sites/all/modules/civicrm/templates/CRM/Case/Form/CaseView.tpl in line 259, which seemed like the correct place in the CaseView.tpl for the activities to appear. I added:
  {if $form.priority_id == 1}
     {$form.file_on_case_activity_subject.label}
  {elseif $form.priority_id == 2}
     {$form.file_on_case_activity_subject.label}
  {/if}
  
  where before we only had:
  {$form.file_on_case_activity_subject.label}
  
  When this didn't work, I tried to set an "urgent" class to the $form.file_on_case_activity_subject.html as well:
  {if $form.priority_id == 1}
            {$form.file_on_case_activity_subject.label}
            {$form.file_on_case_activity_subject.html}
              {ts}You can modify the activity subject before filing.{/ts}
            
          {elseif $form.priority_id == 2}
          {$form.file_on_case_activity_subject.label}
            {$form.file_on_case_activity_subject.html}
              {ts}You can modify the activity subject before filing.{/ts}
            
          {/if}
  
  where before we only had:
  {$form.file_on_case_activity_subject.label}
  {$form.file_on_case_activity_subject.html}
              {ts}You can modify the activity subject before filing.{/ts}
            
  
  As this didn't work either, I suppose I am modifying the wrong place. Any hint anyone?
  Edit: I created an extension with the following code, but it doesn't work yet:
  function mark_urgent_activities_civicrm_buildForm($formName, &$form) {
    if ($formName == 'CRM_Case_Form_CaseView') {
      CRM_Core_Resources::singleton()->addStyle('#crm-container table.nestedActivitySelector tr.priority-urgent {background-color: orange;}');
    }
  }
  
  Edit2: Accessing the elements with priority-urgent class works in the css file, both as
  .priority-urgent {
  font-weight: bold;
  }
  
  and
  #crm-container table.nestedActivitySelector tr.priority-urgent {
  font-weight: bold;
  }
  
  The (background / font) color doesn't work yet, but I suppose that's only because  element cannot have background color.
  
  **Tags:** civicase, activity
  
  > **Comments:**
  > **username_1**: It worked when I tested it - but I didn't restrict to CRM_Case_Form_CaseView. The table is created by magic after the page loads so maybe there's a timing issue if you restrict the form. The background-color worked for me - maybe you have other customizations conflicting?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-10-07. Score: 3 | Accepted answer
  
  If I'm understanding correctly, all you need to do is make an extension and call `CRM_Core_Resources::singleton()->addStyle()` in hook\_buildForm as described at <https://docs.civicrm.org/dev/en/latest/framework/resources/#css-stylesheets> since activities with priority urgent already get class priority-urgent added to the `|
  |  |` element in the table that lists the activities.
  
  e.g.
  `CRM_Core_Resources::singleton()->addStyle('#crm-container table.nestedActivitySelector tr.priority-urgent {background-color: orange;}');`
  
  The `#crm-container table.nestedActivitySelector` part is required because otherwise the more specific css target from core gets applied instead.
  
  > **Comments:**
  > **username_0**: Can you tell me where exactly activities with priority urgent get the class priority-urgent added to the <tr> element? And where does the more specific css target from core get applied?  
  > **username_1**: `grep -r priority-urgent *` - says it's in CRM/Case/BAO/Case.php - line 1022 (I'm using 5.31/dev - line number might be slightly different in other versions.) Similarly the more specific css part is in css/civicrm.css.  
  
  ---
  
  