Answers.Body: <p>Use below</p>
  <pre><code>$('.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', 
    cgcount: '1',
    reset: 1,
    snippet: 5,
    type: 'page'
  }), function() {
    $(this).trigger('crmLoad');
  });
  </code></pre>
  <p>replace</p>
  <ol>
  <li>cid to contact_id</li>
  <li>groupId with custom group Id</li>
  <li>.crm-custom-set-block-5, replace 5 with custom group id</li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-22T13:55:47.983Z
Answers.Text: in my case it is 'form.CRM_Contact_Form_Inline_CustomData' and unfortunately it is not being triggered.
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-22T14:22:42.300Z
Answers.Text: does the custom set is on Summary tab or on its own tab?
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-22T14:32:49.063Z
Answers.Text: is on Summary tab and its equivalent of $el would be e.target.childNodes[3] (which is a div with "crm-container-snippet") class - assuming the result of .crmSnippet(); on the element.
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-22T16:13:43.793Z
Answers.Text: I have updated my answer
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-23T12:05:02.197Z
Answers.Text: I'd say this sends the investigation into the whole new direction. It works! Would you please point me to documentation regarding the solution and  data-edit-params usage ( if exists )? Cheers.
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-23T13:09:31.893Z
Answers.Text: where you want to use data-edit-params?
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-23T18:33:56.917Z
Answers.Text: I was curious where this solution comes from and realized I've seen all the params inside the form "data-edit-params".  Would be nice to read more about how this works, not sure if this piece is documented though.
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-22T12:02:07.353Z
Answers.LastActivityDate: 2023-11-22T16:13:33.960Z
Answers.LastEditDate: 2023-11-22T16:13:33.960Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>Stuck with jQuery, which intercepts a contact Quick Edit and updates a custom field. All is fine and a value gets updated in the database but is not immediately shown, need to click &quot;Edit&quot; again to see it changed.
  Have been searching high and low here <a href="https://docs.civicrm.org/dev/en/latest/framework/ajax/#crmrefreshparent" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/framework/ajax/#crmrefreshparent</a> and in the code for &quot;refreshParent&quot; to no avail. Any pointer in the right direction please?</p>
  <pre><code>CRM.$(function ($) {
  $(document).on('crmFormSuccess', function (e, data) {
      var changedElement = $(this);
      console.log(changedElement);
      if (typeof (data) == 'object') {
          // data.status: success|| form_error
          if (data.status === 'success') {
              const userContext = data.userContext.split('=');
              const cid = userContext[userContext.length - 1];
              CRM.api3('Contact', 'get', {
                  &quot;return&quot;: [&quot;custom_1&quot;, &quot;custom_2&quot;],
                  &quot;id&quot;: cid
              }).then(function (result) {
                      CRM.api3('CustomValue', 'create', {
                          &quot;entity_id&quot;: result.id,
                          &quot;custom_2&quot;: result.values[result.id].custom_1 == &quot;1&quot;?   &quot;1&quot; : &quot;0&quot;
                      }).then(function (result) {
                         // Please, refreshParent, if you can! 
                          }, function (error) {
                          // oops
                      });
              }, function (error) {
                  // oops
              });
          }
      }
   });
  });
  </code></pre>
  
Tags: <javascript><ajax><jquery>
Title: Contact Quick Edit, refreshParent after CRM.api3('CustomValue', 'create)?
ThreadText: # Contact Quick Edit, refreshParent after CRM.api3('CustomValue', 'create)?
  
  (Asked by: username_0 on 2023-11-22)
  
  Stuck with jQuery, which intercepts a contact Quick Edit and updates a custom field. All is fine and a value gets updated in the database but is not immediately shown, need to click "Edit" again to see it changed.
  Have been searching high and low here https://docs.civicrm.org/dev/en/latest/framework/ajax/#crmrefreshparent and in the code for "refreshParent" to no avail. Any pointer in the right direction please?
  CRM.$(function ($) {
  $(document).on('crmFormSuccess', function (e, data) {
      var changedElement = $(this);
      console.log(changedElement);
      if (typeof (data) == 'object') {
          // data.status: success|| form_error
          if (data.status === 'success') {
              const userContext = data.userContext.split('=');
              const cid = userContext[userContext.length - 1];
              CRM.api3('Contact', 'get', {
                  "return": ["custom_1", "custom_2"],
                  "id": cid
              }).then(function (result) {
                      CRM.api3('CustomValue', 'create', {
                          "entity_id": result.id,
                          "custom_2": result.values[result.id].custom_1 == "1"?   "1" : "0"
                      }).then(function (result) {
                         // Please, refreshParent, if you can! 
                          }, function (error) {
                          // oops
                      });
              }, function (error) {
                  // oops
              });
          }
      }
   });
  });
  
  **Tags:** javascript, ajax, jquery
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-11-22. Score: 1 | Accepted answer
  
  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', 
    cgcount: '1',
    reset: 1,
    snippet: 5,
    type: 'page'
  }), function() {
    $(this).trigger('crmLoad');
  });
  
  replace
  
  cid to contact_id
  groupId with custom group Id
  .crm-custom-set-block-5, replace 5 with custom group id
  
  > **Comments:**
  > **username_0**: in my case it is 'form.CRM_Contact_Form_Inline_CustomData' and unfortunately it is not being triggered.  
  > **username_1**: does the custom set is on Summary tab or on its own tab?  
  > **username_0**: is on Summary tab and its equivalent of $el would be e.target.childNodes[3] (which is a div with "crm-container-snippet") class - assuming the result of .crmSnippet(); on the element.  
  > **username_1**: I have updated my answer  
  > **username_0**: I'd say this sends the investigation into the whole new direction. It works! Would you please point me to documentation regarding the solution and  data-edit-params usage ( if exists )? Cheers.  
  > **username_1**: where you want to use data-edit-params?  
  > **username_0**: I was curious where this solution comes from and realized I've seen all the params inside the form "data-edit-params".  Would be nice to read more about how this works, not sure if this piece is documented though.  
  
  ---
  
  