Sample Codes — C#

Modify — C#

Modify a customer’s email address.

            oaCustomer customer = new oaCustomer();
customer.id = "37";
customer.addr_email = "newest@example.com";

UpdateResult[] res =_svc.modify(new OA.Attribute[]{},new oaBase[]{customer}); 

          

Update Using External ID as Foreign Key Lookup — C#

This modify request updates the filterset_ids property of user (id = 12). The API looks up the internal IDs of Filtersets which have external_ids “extrn1”, “extrn2” and “extrn3” and assigns the filterset_ids property of the target user with the list of corresponding internal IDs, like “12,3,24”.

            oaFieldAttribute lookupAttr = new oaFieldAttribute();
lookupAttr.name = "external";
lookupAttr.value = "filterset_ids:Filterset:1";

oaUser user = new oaUser();
user.id = "12";
user.filterset_ids = "extrn1,extrn2,extrn3";
user.attributes = new oaBase[] { lookupAttr };

UpdateResult[] results = _svc.modify(new OA.Attribute[] {}, new oaBase[] { user }); 

          

Update Using Custom Field as Foreign Key Lookup — C#

To use custom field as a lookup field in place of internal ID, use the following syntax. The API will find the customer(s) which have CustField12 value set to “somevalue” and update the name on matching records to “John Carr”.

            oaCustomer customer = new oaCustomer();
customer.name = "John Carr";
customer.CustField12__c = "somevalue";

//this attribute specifies which custom field should be used for lookup
OA.Attribute lookupAttr = new OA.Attribute();
lookupAttr.name = "lookup_custom";
lookupAttr.value = "CustField12__c";

UpdateResult[] results = _svc.modify(new OA.Attribute[] { lookupAttr }, new oaBase[] { customer }); 

          

Update Custom Field Value as Object Property — C#

            oaProject project = new oaProject();
project.id = "123"; //id of record to modify
project.ProjectStatus__c = "Yellow"; //new custom field value

//Define attribute that directs API to update a custom field.
OA.Attribute updateCustom = new OA.Attribute();
updateCustom.name = "update_custom";
updateCustom.value = "1";

UpdateResult[] res = _svc.modify(new OA.Attribute[] { updateCustom },
new oaBase[] { project }); 

          

Modify Custom Field Values with custom equal to Method — C#

            OA.Attribute lookupAttr = new OA.Attribute();
lookupAttr.name = "method";
lookupAttr.value = "custom equal to";

oaCustomField customField = new oaCustomField();
customField.type = "User"; //name of the object the field is associated with
customField.id = "12"; //internal ID of the user record.
customField.name = "cust_field_name"; // internal name of the custom field.
customField.value = "My new value"; // new value

UpdateResult[] updateResults = _svc.modify(new OA.Attribute[] { lookupAttr }, new oaBase[] { customField }); 

          

Modify ImportExport Objects and Read Not Exported — C#

Mark the envelope with ID = 4 as exported by the application MY_APP on 4/1/2008. By doing this, we can later use “not-exported” filter to read only records that have not yet been exported by MY_APP.

            oaImportExport exportRecord = new oaImportExport();
exportRecord.application = "MY_APP";
exportRecord.type = "Envelope";
exportRecord.id = "4";
exportRecord.exported = "2008-04-01 00:00:00";
UpdateResult[] ur = _svc.upsert(new OA.Attribute[] {}, new oaBase[] { exportRecord });

//Define read parameters
ReadRequest rr = new ReadRequest();
rr.method = "all";
rr.type = "Envelope";

//Export only records that have not yet been exported by MY_APP
OA.Attribute notExportedAttr = new OA.Attribute();
notExportedAttr.name = "filter";
notExportedAttr.value = "not-exported";
rr.attributes = new OA.Attribute[] { notExportedAttr };

//Direct the API to filter out records exported by MY_APP
oaImportExport importExport = new oaImportExport();
importExport.application = "MY_APP";
rr.objects = new oaBase[] { importExport };

ReadResult[] results = _svc.read(new ReadRequest[] { rr });