Answers.Body: <p>if it is on drupal module add civicrm_initialize(); method above that line </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-18T11:15:04.473Z
Answers.LastActivityDate: 2016-03-18T11:15:04.473Z
Answers.UserDisplayName: Vakees
Body: <pre><code> if ($formName == 'CRM_Contribute_Form_Contribution_Confirm' &amp;&amp; $form-&gt;_id == 1) {
  
  
     CRM_Core_Resources::singleton()-&gt;addScriptFile(drupal_get_path('module','custom_water') .'/',
       'custom_water.js');
  
  }
  </code></pre>
  
  <p>When I use the above code as mentioned in the link
  <a href="https://wiki.civicrm.org/confluence/display/CRMDOC43/Resource+Reference#ResourceReference-Introduction" rel="nofollow">https://wiki.civicrm.org/confluence/display/CRMDOC43/Resource+Reference#ResourceReference-Introduction</a></p>
  
  <p>Add a Javascript file
  PHP
  CRM_Core_Resources::singleton()->addScriptFile('com.example.foo', 'bar.js');</p>
  
  <p>I get an error : <strong>Fatal error: Class 'CRM_Core_Resources' not found in</strong></p>
  
  <p>I am using drupal 7 with CiviCRM</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-03-20T16:58:21.123Z
Comments.Text: I think the error message you're posting got cut off, please finish it?  Also, are you adding this code to a Drupal module or CiviCRM extension?
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-03-21T07:26:51.940Z
Comments.Text: @JonG I am adding the code in drupal module
Comments.UserDisplayName: harshal
Tags: <drupal><javascript>
Title: Fatal error: Class 'CRM_Core_Resources' not found in
ThreadText: # Fatal error: Class 'CRM_Core_Resources' not found in
  
  (Asked by: username_0 on 2016-03-12)
  
  if ($formName == 'CRM_Contribute_Form_Contribution_Confirm' && $form->_id == 1) {
  
  
     CRM_Core_Resources::singleton()->addScriptFile(drupal_get_path('module','custom_water') .'/',
       'custom_water.js');
  
  }
  
  When I use the above code as mentioned in the link
  https://wiki.civicrm.org/confluence/display/CRMDOC43/Resource+Reference#ResourceReference-Introduction
  Add a Javascript file
  PHP
  CRM_Core_Resources::singleton()->addScriptFile('com.example.foo', 'bar.js');
  I get an error : Fatal error: Class 'CRM_Core_Resources' not found in
  I am using drupal 7 with CiviCRM
  
  **Tags:** drupal, javascript
  
  > **Comments:**
  > **username_1**: I think the error message you're posting got cut off, please finish it?  Also, are you adding this code to a Drupal module or CiviCRM extension?  
  > **username_0**: @JonG I am adding the code in drupal module  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2016-03-18. Score: 0 | Accepted answer
  
  if it is on drupal module add civicrm\_initialize(); method above that line
  
  
  ---
  
  