UpdateCollection
Use UpdateCollection to perform updates on data, which includes insertion, modification, and deletion of data. UpdateCollection requests are constructed using the UpdateCollectionRequestData IDO protocol class.
Properties
These properties are available on the UpdateCollectionRequestData class:
Property | Data Type | Description |
---|---|---|
IDOName | System.String | Identifies the IDO used to execute the request |
CollectionID | System.String | Specifies an identifier associated with this UpdateCollection request |
RefreshAfterUpdate | System.Boolean | Specifies a boolean value used to indicate if the caller wants the response to contain the updated items refreshed after they were saved |
CustomInsert CustomUpdate CustomDelete |
System.String | Specifies the properties used for custom actions that
are used to save items Note: This property is the same as a custom
INS/UPD/DEL in Windows client.
|
LinkBy | Mongoose.IDO.Protocol. PropertyPair array | Applies to inner nested UpdateCollection requests only
and specifies the relationship between a parent and child IDO in
terms of property pairs Use the SetLinkBy method to set this property. Default: Empty |
Items | Mongoose.IDO.Protocol. IDOUpdateItems | Specifies an instance of the IDOUpdateItems class that
contains zero or more IDOUpdateItem instances The IDOUpdateItem class contains the update information for a single item |
TxnScope | Mongoose.IDO.Protocol.TxnScope | If set to Item, each individual
item in the UpdateCollection request is saved in a separate
transaction For a hierarchical (nested) UpdateCollection request, the value of the TxnScope attribute at the root level determines the behavior for the entire UpdateCollection request. This attribute has no effect when it is included in an inner UpdateCollection within hierarchical requests. |
UpdateCollection example
To execute an UpdateCollection request, first construct an instance of the UpdateCollectionRequestData class, and pass it to the UpdateCollection method on the IIDOCommands interface.
UpdateCollectionRequestData request = new UpdateCollectionRequestData(); UpdateCollectionResponseData response; IDOUpdateItem newCust = new IDOUpdateItem(); request.IDOName = "SLCustomers"; request.RefreshAfterUpdate = true; newCust.Action = UpdateAction.Insert; newCust.ItemNumber = 1; // used for error reporting newCust.Properties.Add( "CustNum", "C000100" ); newCust.Properties.Add( "Name", "Boxmart" ); newCust.Properties.Add( "CurrCode", "USD" ); newCust.Properties.Add( "BankCode", "BK1" ); request.Items.Add( newCust ); response = this.Context.Commands.UpdateCollection( request );
LoadCollection/UpdateCollection example: saving changes to existing records
This example loads data from an IDO, updates the data and saves the collection.
public void DoUpdate() { LoadCollectionResponseData loadresponse; string sFilter = "CoNum = 'C0000567'"; loadresponse = this.Context.Commands.LoadCollection("SLCos", "Charfld1, CustNum", sFilter, "", -1); if ( loadresponse.Items.Count > 0 ) { UpdateCollectionRequestData updateRequest; IDOUpdateItem updateItem; // Create a new UpdateCollection request: updateRequest = new UpdateCollectionRequestData("SLCos"); // Create a new update item for the row we loaded: updateItem = new IDOUpdateItem(UpdateAction.Update, loadresponse.Items[0].ItemID); // Add the CustNum property from LoadResposne, not modified: updateItem.Properties.Add("CustNum",loadresponse[0,"CustNum"].Value, false); // Add the Charfld1 property using a new value, modified: updateItem.Properties.Add(“Charfld1”, “Owzat?”, true); // Add the update item to update the request: updateRequest.Items.Add(updateItem); // Save the changes: this.Context.Commands.UpdateCollection(updateRequest); } }