Answers.Body: <p>Rename ContactType label </p>
  
  <pre><code>$result = civicrm_api3('ContactType', 'create', array(
    'sequential' =&gt; 1,
    'id' =&gt; 1,
    'label' =&gt; "test",
  ));
  </code></pre>
  
  <p>This example will rename ContactType Label </p>
  
  <p>I guess this helps !!!!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-22T11:02:58.667Z
Answers.Text: Yes, I can confirm that this is the right approach. So to update existing ContactType you need to first query the id with 'get' and then use the returned 'id' and only the data that needs changing, in this case the label. Still don't understand how you would do that "chained", for instance when you only know 'name'
Answers.UserDisplayName: ñull
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-22T11:39:19.093Z
Answers.Text: @ñull You can chain it like this, for a given `contact_id` for example you would do `$result = civicrm_api3('Contact', 'getsingle', array(
    'sequential' => 1,
    'id' => 2,
    'api.ContactType.get' => array( 'name' => '$value.contact_type' ),
  ));` Does that help?
Answers.UserDisplayName: Andrei
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-23T09:41:39.997Z
Answers.Text: No, not really @Andrei, but thank you any way! I will experiment with this and when necessary post a more specific question separately.
Answers.UserDisplayName: ñull
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-23T11:16:44.607Z
Answers.Text: See my other question: http://civicrm.stackexchange.com/questions/12578/how-to-update-contenttype-label-through-api-chaining
Answers.UserDisplayName: ñull
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-22T10:18:33.173Z
Answers.LastActivityDate: 2016-06-22T10:18:33.173Z
Answers.UserDisplayName: Ramesh - ARTECH Consultancy
Body: <p>Attempting to write prototype initialisation code I want to rename a ContactType using the API action "create". I tried to set: </p>
  
  <ul>
  <li>array ('parent_id' => 0)</li>
  <li>array ('parent_id' => '')</li>
  </ul>
  
  <p>But both error out with "Mandatory key(s) missing from params array: parent_id". 
  I cannot set array('parent_id' => NULL), because it would be like unsetting 'parent_id' which according to the error message cannot be missing. So the question is how do you set it NULL or how do you rename the label of a ContactType using the API? </p>
  
  <p>Edited: Then I discovered that apparently you need the ID of the ContactType when you want to update with 'create', following the instruction that the API explorer gives me when I choose 'update': </p>
  
  <blockquote>
    <p>The "update" action is deprecated. Use "create" with an id instead.</p>
  </blockquote>
  
  <p>So I added id as parameter and kept trying ways to set 'parent_id' correctly to NULL. I discovered that array('parent_id' => '0') is the likely way to do that, because it returned a different error message: "already exists". Well yes, I knew that. My intention was to update the label with 'create" according apparently a wrong instruction. Or is this a bug?</p>
  
Tags: <api><contact-types>
Title: How to set API ContactType parent_id NULL or how to rename label?
ThreadText: # How to set API ContactType parent_id NULL or how to rename label?
  
  (Asked by: username_0 on 2016-06-22)
  
  Attempting to write prototype initialisation code I want to rename a ContactType using the API action "create". I tried to set:
  
  * array ('parent\_id' => 0)
  * array ('parent\_id' => '')
  
  But both error out with "Mandatory key(s) missing from params array: parent\_id".
  I cannot set array('parent\_id' => NULL), because it would be like unsetting 'parent\_id' which according to the error message cannot be missing. So the question is how do you set it NULL or how do you rename the label of a ContactType using the API?
  
  Edited: Then I discovered that apparently you need the ID of the ContactType when you want to update with 'create', following the instruction that the API explorer gives me when I choose 'update':
  
  > The "update" action is deprecated. Use "create" with an id instead.
  
  So I added id as parameter and kept trying ways to set 'parent\_id' correctly to NULL. I discovered that array('parent\_id' => '0') is the likely way to do that, because it returned a different error message: "already exists". Well yes, I knew that. My intention was to update the label with 'create" according apparently a wrong instruction. Or is this a bug?
  
  **Tags:** api, contact-types
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-06-22. Score: 1 | Accepted answer
  
  Rename ContactType label
  
  ```
  $result = civicrm_api3('ContactType', 'create', array(
    'sequential' => 1,
    'id' => 1,
    'label' => "test",
  ));
  
  ```
  
  This example will rename ContactType Label
  
  I guess this helps !!!!
  
  > **Comments:**
  > **username_0**: Yes, I can confirm that this is the right approach. So to update existing ContactType you need to first query the id with 'get' and then use the returned 'id' and only the data that needs changing, in this case the label. Still don't understand how you would do that "chained", for instance when you only know 'name'  
  > **username_2**: @username_0 You can chain it like this, for a given `contact_id` for example you would do `$result = civicrm_api3('Contact', 'getsingle', array(   'sequential' => 1,   'id' => 2,   'api.ContactType.get' => array( 'name' => '$value.contact_type' ), ));` Does that help?  
  > **username_0**: No, not really @username_2, but thank you any way! I will experiment with this and when necessary post a more specific question separately.  
  > **username_0**: See my other question: http://civicrm.stackexchange.com/questions/12578/how-to-update-contenttype-label-through-api-chaining  
  
  ---
  
  