Answers.Body: <p>The syntax you gave is correct. I suggest you:</p>
  
  <ol>
  <li>Ensure your code is actually running (add a debug statement or <code>exit();</code> in your code).</li>
  <li>Clear your caches. If your page is being cached by the cms then that might be why you're not seeing it.</li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-06T18:17:49.323Z
Answers.Text: Thanks for the answer Coleman, but I'm still having the problem.
Answers.UserDisplayName: bdombro
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-03T17:32:53.993Z
Answers.LastActivityDate: 2015-05-03T17:32:53.993Z
Answers.UserDisplayName: Coleman
Body: <p>I'm calling this from a hook but it's not working.  Am I doing something wrong?</p>
  
  <p>CRM_Core_Resources::singleton()->addScript("alert('hello');");</p>
  
  <p>I confirmed that it's running by adding debug code to addScript.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-02T01:47:07.887Z
Comments.Text: It works fine when I try it. Are you sure your hook is being called?
Comments.UserDisplayName: Coleman
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-03T14:38:06.843Z
Comments.Text: Okay, thanks for confirming that I'm doing it correctly.  When I get a chance, I'll try to debug core and figure out why it's not working for me.
Comments.UserDisplayName: bdombro
Tags: <hooks>
Title: How do I add Javascript to pages using Core functions?
ThreadText: # How do I add Javascript to pages using Core functions?
  
  (Asked by: username_0 on 2015-05-01)
  
  I'm calling this from a hook but it's not working. Am I doing something wrong?
  
  CRM\_Core\_Resources::singleton()->addScript("alert('hello');");
  
  I confirmed that it's running by adding debug code to addScript.
  
  **Tags:** hooks
  
  > **Comments:**
  > **username_1**: It works fine when I try it. Are you sure your hook is being called?  
  > **username_0**: Okay, thanks for confirming that I'm doing it correctly.  When I get a chance, I'll try to debug core and figure out why it's not working for me.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-05-03. Score: 1
  
  The syntax you gave is correct. I suggest you:
  
  1. Ensure your code is actually running (add a debug statement or `exit();` in your code).
  2. Clear your caches. If your page is being cached by the cms then that might be why you're not seeing it.
  
  > **Comments:**
  > **username_0**: Thanks for the answer username_1, but I'm still having the problem.  
  
  ---
  
  