1

I want to replace a word. I was trying to insert using API3 but it is not working properly.

Word replacement API3

$result = civicrm_api3('WordReplacement', 'create', [
  'find_word' => "Contacts",
  'replace_word' => "Data",
  'id' => 1,
]);

Output {

"is_error": 0,
"version": 3,
"count": 1,
"id": 1,
"values": {
    "1": {
        "id": "1",
        "find_word": "Contacts",
        "replace_word": "Data",
        "is_active": "",
        "match_type": "",
        "domain_id": "1"
    }
}


But the values are not stored in 'civicrm_word_replacement' table. Please give some suggestion. When I am trying to insert a value using custom php script then it is showing me a following error.

PHP Fatal error:  Uncaught Error: Call to undefined function _drupal_flush_css_js() in C:\xampp\htdocs\copy\sites\all\modules\civicrm\CRM\Utils\System\DrupalBase.php:300
0

Your code includes 'id' => 1

create with an id is for updating an existing value. Do you already have a WordReplacement with id=1 ?

If you are wanting to create a new one rather than update, just omit 'id' => 1

  • But I want to edit a values of id 1. – deepak Mar 5 at 11:58
  • 1
    Ok, that's not how I interpreted your question. What output do you get from cv api WordReplacement.get ? – Aidan Mar 5 at 12:08
0

It looks like you are creating it disabled?

    "is_active": "",

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.