Quantcast
Viewing all articles
Browse latest Browse all 2504

Connect for PHP: Clear Custom Field Value (3 Comments)

Topic by Christopher Farmer

Hi,

I'm trying to clear the value of an incident custom field (c$thread_update) of type Text Area using the Connect for PHP API.

The documentation states that a contact custom field value can be cleared using the following code:

$contact = RNCPHP\Contact::fetch(128);

$contact->CustomFields->c->login_name = null;

$contact->save();

However, when I try something similar with an incident's custom field, the value is not cleared. In fact, the value does not change at all:

            $incident = RNCPHP\Incident::fetch($incidentID, RNCPHP\RNObject::VALIDATE_KEYS_OFF);
            
            // Initialise the incident's custom fields
            $incidentMetaData     = $incident::getMetadata();
            $custFieldsTypeName = $incidentMetaData->CustomFields->type_name;
            $custFieldsMetaData = $custFieldsTypeName::getMetadata();
            $incident->CustomFields->c = new $custFieldsMetaData->c->type_name();
            
            // Clear the value of the thread_update field
            $incident->CustomFields->c->thread_update = null;

When I try changing the value of this custom field to anything other than null e.g. 'TEST', the value changes correctly, so I know the code is all working as expected otherwise.

Could anyone advise where I'm going wrong?

Any help would be greatly appreciated!

Many thanks.


Viewing all articles
Browse latest Browse all 2504

Trending Articles