Modify — Java
// Modify customer's email address
oaCustomer customer1 = new oaCustomer();
customer1.setAddr_email("new@example.com");
customer1.setId("66");
// Attribute not used in this case but needs to be passed in.
Attribute dummy = new Attribute();
UpdateResult[] results = binding.modify(new Attribute[] { dummy },
new oaBase[] { customer1 });
Modify with Foreign Key Lookup — Java
// For each xxxid field that needs to be looked up, set the ID field (filtersetids) to the externalid field value.
// Create an oaFieldAttribute object and set its members. In this example, filtersetids accepts a list of OpenAir internal IDs separated by a comma. In most cases just a single ID values is used.
oaFieldAttribute attr = new oaFieldAttribute();
att.setName("external"); // type of lookup (external will lookup the field using external_id field)
attr.setValue("filtersetids:Filterset:1"); // colon separated values: field name (as it exists in the object, matching record type to process lookup for, 1 is needed to process comma separated values (it's not required for regular fields)
// Set the user field (filtersetids in this case, to the value of the externalid (instead of the internalid used normally)
oaUser user = new oaUser();
user.setId("10119");
user.setFiltersetids("external1,external2,external3,external4");
// notice that the field used (filtersetids) matches the first part of the attributes value.
// Set the attributes collection for user object. Set the attribute as part of collection.
user.setAttributes(new oaBase[] {attr});
// process modify
UpdateResult[] results = service.modify(new Attribute[] { null}, new oaBase[] {user});
Modify Custom Field Values with custom equal to Method — Java
// Attributes can be used to specify non-default method to update custom fields for a given object:
// create the attribute to specify method.
Attribute custom = new Attribute();
custom.setName("method");
custom.setValue("custom equal to");
// create custom field object
oaCustomField customf = new oaCustomField();
customf.setType("User"); // name of the object custom field is associated with. In this example, it is User. See table of custom equal to objects.
customf.setName("userc"); // internal name of the custom field.
customf.setId("1"); // internal ID of the user record
customf.setValue("My new value"); // custom value
UpdateResult[] updateResults = stub.modify(new Attribute[] { custom }, new oaBase[] { customf });
Modify Not Exported Expense Reports — Java
// To modify and read not-yet exported envelopes
// mark the envelope with ID = 4 as exported by the application
// MY_APP on 4/1/2008. By doing this, we can add a filter attribute to
// our read call that will filter out records exported by MY_APP.
oaImportExport exportRecord = new oaImportExport();
exportRecord.setApplication( "MY_APP" );
exportRecord.setType( "Envelope" );
exportRecord.setId( "4" );
exportRecord.setExported( "2008-04-01 00:00:00" );
UpdateResult[] ur = binding.upsert( new Attribute[]{}, new oaBase[] {
exportRecord });
// Now do a read of all envelopes, but add a filter
// so we only retrieve not-yet-exported records
Attribute attr = new Attribute();
attr.setName( "filter" );
attr.setValue( "not-exported" );
ReadRequest read = new ReadRequest();
read.setMethod( "all" );
read.setType( "Envelope" );
read.setAttributes( new Attribute[]{attr} );
// tell the server we're filtering on import_export records created by MY_APP
oaImportExport importExport = new oaImportExport();
importExport.setApplication( "MY_APP" );
read.setObjects( new oaBase[] { importExport } );
ReadResult[] results = binding.read(new ReadRequest[] { read });