Quantcast
Channel: Discussion Forum > Connect Data Services
Viewing all articles
Browse latest Browse all 2504

Creating an Incident with CustomFields using SOAP / PHP

$
0
0

Topic by Roy

Content

I have been able to create most operations through SOAP, but I keep running into problems when I try to add CustomFields belonging to a "package" called ABC to an Incident. I have structured the Incident object exactly the same as the object I get when I retrieve an Incident, but I keep getting the following error:

SOAP faultstring: Expected ObjectValue for property ABC While processing GenericFields[0]: ABC While processing Incident->CustomFields(rng_v1_2::GenericObject).

The PHP code looks like this:

    $GenericField3 = new GenericField();
    $GenericField3->name = 'abc_id';
    $DataValue3 = new DataValue();
    $DataValue3->StringValue = '1234';
    $GenericField3->DataValue = $DataValue3;
    
    $GenericField4 = new GenericField();
    $GenericField4->name = 'abc_key';
    $DataValue4 = new DataValue();
    $DataValue4->StringValue = 'abcdef';
    $GenericField4->DataValue = $DataValue4;

    $genericObject = new GenericObject();
    $genericObjectType = new ObjectType();
    $genericObjectType->TypeName = 'IncidentCustomFieldsABC';
    $genericObject->ObjectType = $genericObjectType;
    $genericObject->GenericFields = array($GenericField3,$GenericField4);
    
    $DataValue = new DataValue();
    $DataValue->ObjectValue = $genericObject;
    
    $GenericField = new GenericField();
    $GenericField->name = 'ABC';
    $GenericField->DataValue = $DataValue;
    
    $CustomFields = new GenericObject();
    $CustomFieldsType = new ObjectType();
    $CustomFieldsType->TypeName = 'IncidentCustomFields';
    $CustomFields->ObjectType = $CustomFieldsType;
    $CustomFields->GenericFields = array($GenericField);
    
    $Incident->CustomFields = $CustomFields;

When I look at the XML being generated it's obvious that there is something wrong as it doesn't contain and fields called abc_id or abc_key (which explains the fault response):

<ns1:CustomFields>
       <ns2:ObjectType>
         <ns2:Namespace xsi:nil="true"/>
         <ns2:TypeName>IncidentCustomFields</ns2:TypeName>
       </ns2:ObjectType>
       <ns2:GenericFields name="ABC">
         <ns2:DataValue/>
       </ns2:GenericFields>
     </ns1:CustomFields>

Getting the SOAP API to work in the first place was quite a challenge, but once you understand the (quite complex) RightNow model I was able to create all the operations I needed. Unfortunately these custom fields are quite important for the entire flow to work as we designed... if anyone has any ideas I would be very grateful :)

I hope Oracle / RightNow adds some clearer examples and documentation for PHP to this site, that would make life a lot easier.

Version

1.2

Code Block


Viewing all articles
Browse latest Browse all 2504

Trending Articles