Skip Navigation
Expand
Updating a custom field with Connect for PHP
Answer ID 10513   |   Last Review Date 09/26/2019

How do I update a custom field with ConnectPHP?

Environment:

Version February 2017 and newer, Connect Common object Model (CCOM) version 1.3 and newer

Resolution:

Custom fields are set when the save() method is called on any primary object.

Please see the sample code below that demonstrates setting a value for a menu_field type custom field:

$incident = RNCPHP\Incident::fetch(1);
$incident->Subject = "Subject updated";
$incident->CustomFields->c->text_field = "new value";
$incident->CustomFields->c->menu_field = new RNCPHP\NamedIDLabel() ;
$incident->CustomFields->c->menu_field->LookupName = 'value 1';
$incident->CustomFields->c->integer_field = 123;
$incident->save(RNCPHP\RNObject::SuppressAll);


Note: The NamedIDLabel object will only allow a value to be assigned once. Assigning more than once will result in an exception indicating "Not allowed: NamedID.ID already set". Overwriting an already assigned value will require a new instantiation of the NamedIDLabel object. 

For additional information please visit: Answer ID 5169: Technical Documentation and Sample Code

Available Languages for this Answer:

Notify Me
The page will refresh upon submission. Any pending input will be lost.