6 votes
Accepted

CiviCRM Ajax API - Searching by Tag

you are almost there: instead of using the tag name, use the tag id (eg 5 for Volunteers) CRM.api3('Contact', 'get', { "debug": 1, "sequential": 1, "return": ["tag"], "tag": "5" }).done(...
Xavier's user avatar
  • 10.2k
5 votes
Accepted

How to go about making a Core Tab on the Contact Summary screen view Inline instead?

Rather than smarty, JavaScript will do the trick. Those tabs are all separate pages, and you can load any CiviCRM page/form as a snippet instead. First, in your extension, use a hook to include the ...
Andie Hunt's user avatar
  • 7,452
4 votes
Accepted

How to update contact email with JavaScript API?

There are many ways you can update email for contact Using Email api with create action CRM.api3('Email', 'create', {"email": "[email protected]", "id": 201}).done(function(result) { // do something}...
Pradeep Nayak's user avatar
3 votes
Accepted

Getting a Custom Field Value on a Contact with Javascript API

The syntax is incorrect - and I just confirmed that the syntax generated by the API Explorer for Getvalue is incorrect, so you're not to blame! The culprit is this line: "return": ["custom_102"], ...
Jon G - Megaphone Tech's user avatar
3 votes

JavaScript Errors / CRM.$ is not a function

Figured it out after some troubleshooting. On the Drupal theme being used, the minified JS (including jQuery) was being put at the end of the page and not present when Civi JS is executed.
user3827's user avatar
  • 138
3 votes

How can I resolve Civi Dashboard Javascript error: widget.name is null?

I'm glad you found the cause of your problem. It does sound like something went wrong back when you originally created those dashlets, and it's not clear what that was. But it would be good to ...
Coleman's user avatar
  • 18.6k
3 votes
Accepted

Drupal's Aggregate Javascript breaks CKEditor Config

You're right, that was a bug. I poked around and found a spot for the js that doesn't break under aggregation: https://github.com/civicrm/civicrm-core/pull/7711
Coleman's user avatar
  • 18.6k
3 votes

How to get contact id of logged-in user in JS API

In case of an angular page use something like function myext_civicrm_angularModules(&$angularModule) { [...] $session =& CRM_Core_Session::singleton(); drupal_add_js(array('...
nielo's user avatar
  • 1,304
3 votes

Unable to create a new mailing

Found the problem. Debugging was turned on. Once I turned it off "New Mailing" worked.
Nina Gonzalez's user avatar
3 votes
Accepted

Jquery not affecting custom fields of an activity

In some CiviCRM pages/forms custom fields are loaded/reloaded via AJAX (you will notice that if you have a set of custom fields based on Activity type, the custom fields update/reload when changing ...
Andrei's user avatar
  • 2,321
3 votes
Accepted

How to pre-fill price or "other amount" from the querystring in payment pages

Below code should work if you have amount parameter set in the url for example amount=300&id=10&reset=1 jQuery(document).ready(function() { let amount = new URLSearchParams(window.location....
Pradeep Nayak's user avatar
2 votes

hide select box options in contributed page

First - don't edit anything in the templates_c directory! These are cached pre-compiled copies of the template, and are frequently cleared out. Second - it's not advisable to edit the templates that ...
Jon G - Megaphone Tech's user avatar
2 votes
Accepted

Javascript MIME type mismatch error after server move

The X-Content-Type-Options: nosniff header is a security measure that prevents the browser from attempting to detect the MIME type of a download automatically, as this behavior can be exploited for ...
choster's user avatar
  • 1,900
2 votes

How to get contact id of logged-in user in JS API

For a Javascript-only solution, you can also make an API call using user_contact_id for the contact ID. For instance: $result = civicrm_api3('Contact', 'get', [ 'sequential' => 1, 'return' =&...
Jon G - Megaphone Tech's user avatar
2 votes
Accepted

After upgrade to 4.7.23., icons do not show (Civicrm on WordPress) (SOLVED)

Following my comment - You need to provide existing path in the resource url and directories page. Click the help icon to see the values of diferent global variables that you can make use of(civicrm....
jitendra - fuzion's user avatar
2 votes
Accepted

Civicontribute radiobuttons without "none", where the "Other" contribution field deselects radiobuttons

This code worked for me: CRM.$(function($) { $('input[type=text]', '#priceset').on('keyup', function() { if ($(this).val()) { $('input[type=radio]:checked', '#priceset').prop('checked', ...
Coleman's user avatar
  • 18.6k
2 votes

Wordpress Ajax & pictures not loading after upgrade to 5.0

I can see the problem (I saw this myself recently), but I don't have a 100% answer. However, the solution is usually to rebuild your multilingual schema. This problem is characterized by: ...
Jon G - Megaphone Tech's user avatar
2 votes

status page not loading nor new mailing page

Generically: You have a Javascript error, so I would definitely consult the Troubleshoot Javascript errors post which describes additional steps to try. That said - I know what your problem is, and ...
Jon G - Megaphone Tech's user avatar
2 votes

Jquery not affecting custom fields of an activity

Ok What's happening is this. If you look at your .crm-accordion-header css rules in an Inspector window in your browser, you will see there is a background-color !important rule earlier in the CSS ...
Tony Horrocks's user avatar
2 votes
Accepted

How do I trigger a price calculation update on the event registration page?

Here's how we do it: We do the two sets of items in a separate price field on the same price set. So the paid options that are required would be in one field, the complementary in another (or several ...
Jenni Simonis's user avatar
2 votes

Where in the CiviCRM codebase do css and js resources get output for an AJAX url or snippet?

I haven't found the answer to this question, but I can avoid it instead. These functions: CRM_Core_Resources::singleton()->addScriptUrl() CRM_Core_Resources::singleton()->addScriptFile() ...
Alan Dixon's user avatar
  • 6,841
2 votes

Why does nesting Civi shortcodes in Wordpress pages prevent Javascript files from loading?

https://developer.wordpress.org/reference/functions/get_shortcode_regex/ "get_shortcode_regex" doesn't seem to work when nesting CiviCRM shortcodes. I found 2 hacky workarounds.
dsmith63's user avatar
  • 419
2 votes
Accepted

How do I use the javascript field in the price_sets table of the database

I don't see any evidence that that field was ever used for anything. If you want to insert javascript into the page see https://docs.civicrm.org/dev/en/latest/framework/resources/#javascript which you ...
Demerit's user avatar
  • 22.9k
2 votes
Accepted

How to set ckeditor text with javascript

Use the CKEditor method setData(): CKEDITOR.instances['custom_162_126'].setData('blub');
Pradeep Nayak's user avatar
2 votes

Event config page suddenly not working

For anyone else who might have this same snafu, this was what happened: Asset caching had been enabled in Debugging and Error Handling I usually set this as disabled, but we have been working on ...
BubbaWanders's user avatar
2 votes
Accepted

Contact Quick Edit, refreshParent after CRM.api3('CustomValue', 'create)?

Use below $('.crm-custom-set-block-5 .crm-summary-block').load(CRM.url('civicrm/ajax/inline', { cid: '133', class_name: 'CRM_Contact_Page_Inline_CustomData', groupID: '5', customRecId: '1', ...
Pradeep Nayak's user avatar
2 votes
Accepted

How to add JavaScript to an AJAX snippet

The buildForm hook works for popups too. TIP: put some logging in a buildForm hook to log the $formName, then visit the page you're interested in. If you're interested in new case, see https://lab....
Demerit's user avatar
  • 22.9k
1 vote
Accepted

How can I configure my contribution page so that recurring is not pre-selected by default?

Actually in the iATS Extension we've gone back and forth on this but are now "is.checked" as many orgs/administrators make special "Donate monthly now" pages with specific appropriate defaults for ...
KarinG - Semper IT's user avatar
1 vote

How can I trigger a selection for a Select2 EntityRef element via javascript?

According to this related question, it should be possible to do this via: $('#id-of-select2').select2('val', 'value-to-select'); or, if you want to select multiple items in a multiselect: $('#id-of-...
Chris Burgess's user avatar
1 vote

Ajax error when viewing relationships under IIS and Joomla (HTTP400 - invalid syntax)

After months of struggling with this, I think I have solved it: I found this article or others like it: https://stackoverflow.com/questions/8159321/request-exceeds-the-configured-maxquerystringlength-...
Stephen Palmstrom's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible