Skip to main content

<a id=“SuperOffice_WebApi_Agents_CustomObjectAgent”></a> Class CustomObjectAgent

Namespace: SuperOffice.WebApi.Agents
Assembly: SuperOffice.WebApi.dll
Agent for working with Custom Objects (extra tables): read schema and full CRUD over rows. Purpose-built replacement for using DatabaseTableAgent against custom objects.

Inheritance

objectAgentBaseCustomObjectAgent

Implements

ICustomObjectAgent, IAgentBase, IDisposable

Inherited Members

AgentBase._json, AgentBase._binary, AgentBase._config, AgentBase._client, AgentBase._disposeClient, AgentBase.Merge(RequestOptions), AgentBase.BuildRequestFromObject(HttpMethod, string, object, WebApiOptions, string), AgentBase.BuildRequestFromStream(HttpMethod, string, Stream, WebApiOptions, string), AgentBase.BuildRequestFromObjectWithStream(HttpMethod, string, object, Stream, WebApiOptions, string), AgentBase.ParseAuthorization(IAuthorization), AgentBase.CancelRequest(), AgentBase.SendRequestObject(HttpMethod, string, object, WebApiOptions, string), AgentBase.SendRequestObjectWithStream(HttpMethod, string, object, Stream, WebApiOptions, string), AgentBase.SendRequest(HttpRequestMessage, RequestOptions), AgentBase.ThrowOnResponseErrorAsync(HttpRequestMessage, HttpResponseMessage), AgentBase.ParseResponse<T&gt;(HttpResponseMessage), AgentBase.Finally(RequestOptions), AgentBase.Dispose(), AgentBase.Configuration, AgentBase.Client, AgentBase.HasRunningRequest, AgentBase.ClientCancellationTokenSource, AgentBase.ProgressListener, AgentBase.UploadProgressListener, object.ToString(), object.Equals(object), object.Equals(object, object), object.ReferenceEquals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone()

Examples

<pre><code class=“lang-csharp”>using SuperOffice.WebApi; using SuperOffice.WebApi.Agents; var mySession = new WebApiOptions(“http://example.com/super/api”); mySession.Authorization = new AuthorizationUsernamePassword(“user”, “pass”); using (CustomObjectAgent agent = new CustomObjectAgent(mySession)) { // call methods on agent here… }</code></pre>

Constructors

<a id=“SuperOffice_WebApi_Agents_CustomObjectAgent__ctor_System_Net_Http_HttpClient_”></a> CustomObjectAgent(HttpClient)

Constructor: Agent for working with Custom Objects (extra tables): read schema and full CRUD over rows. Purpose-built replacement for using DatabaseTableAgent against custom objects.

Parameters

httpClient HttpClient Use this HTTP client instead of making own HttpClient instance.

<a id=“SuperOffice_WebApi_Agents_CustomObjectAgent__ctor_SuperOffice_WebApi_WebApiOptions_System_Net_Http_HttpClient_”></a> CustomObjectAgent(WebApiOptions, HttpClient)

Constructor: Agent for working with Custom Objects (extra tables): read schema and full CRUD over rows. Purpose-built replacement for using DatabaseTableAgent against custom objects.

Parameters

options WebApiOptions Base URL and authentication values. httpClient HttpClient Optional: Use this HTTP client instead of making a new one.

Methods

<a id=“SuperOffice_WebApi_Agents_CustomObjectAgent_CreateDefaultCustomObjectAsync_System_String_SuperOffice_WebApi_RequestOptions_”></a> CreateDefaultCustomObjectAsync(string, RequestOptions)

Returns a new Custom Object row pre-populated with the default values declared by the Custom Object Definition. The row is not yet persisted.

Parameters

definitionName string Database table name of the Custom Object Definition, e.g. ‘y_equipment’. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<CustomObject&gt; A new Custom Object row pre-populated with default values. Not yet persisted.

<a id=“SuperOffice_WebApi_Agents_CustomObjectAgent_CreateDefaultCustomObjectDefinitionAsync_SuperOffice_WebApi_RequestOptions_”></a> CreateDefaultCustomObjectDefinitionAsync(RequestOptions)

Set default values into a new CustomObjectDefinition. NetServer calculates default values on the entity, which is required when creating/storing a new instance

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<CustomObjectDefinition&gt; A blank CustomObjectDefinition

<a id=“SuperOffice_WebApi_Agents_CustomObjectAgent_DeleteCustomObjectAsync_System_String_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> DeleteCustomObjectAsync(string, int, RequestOptions)

Deletes a single Custom Object row by primary key.

Parameters

definitionName string Database table name of the Custom Object Definition, e.g. ‘y_equipment’. id int Primary key of the row to delete. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task This method has no return value

<a id=“SuperOffice_WebApi_Agents_CustomObjectAgent_GetCustomObjectAsync_System_String_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> GetCustomObjectAsync(string, int, RequestOptions)

Returns a single Custom Object row by definition name and primary key.

Parameters

definitionName string Database table name of the Custom Object Definition, e.g. ‘y_equipment’. id int Primary key of the row to fetch. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<CustomObject&gt; The Custom Object row, or null if no row with that id exists.

<a id=“SuperOffice_WebApi_Agents_CustomObjectAgent_GetCustomObjectDefinitionAsync_System_String_SuperOffice_WebApi_RequestOptions_”></a> GetCustomObjectDefinitionAsync(string, RequestOptions)

Returns the schema (table + field definitions) for a Custom Object Definition by its database table name.

Parameters

definitionName string Database table name of the Custom Object Definition, e.g. ‘y_equipment’. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<CustomObjectDefinition&gt; The Custom Object Definition, or null if no definition with that name exists.

<a id=“SuperOffice_WebApi_Agents_CustomObjectAgent_GetCustomObjectsIconsAsync_SuperOffice_WebApi_RequestOptions_”></a> GetCustomObjectsIconsAsync(RequestOptions)

Returns SVG icon data for all Custom Object tables, keyed by table name.

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<StringDictionary&gt; Map of table name to SVG icon data URI.

<a id=“SuperOffice_WebApi_Agents_CustomObjectAgent_GetCustomObjectsMetadataAsync_SuperOffice_WebApi_RequestOptions_”></a> GetCustomObjectsMetadataAsync(RequestOptions)

Returns bootstrap metadata for all Custom Object tables.

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<CustomObjectMetadata[]&gt; Metadata for all custom object tables.

<a id=“SuperOffice_WebApi_Agents_CustomObjectAgent_HasScreenChooserAsync_System_String_System_Boolean_SuperOffice_WebApi_RequestOptions_”></a> HasScreenChooserAsync(string, bool, RequestOptions)

Returns true if a screen chooser is configured for the given Custom Object Definition and mode.

Parameters

definitionName string Database table name of the Custom Object Definition. edit bool True to check for a custom edit screen; false to check for a custom view screen. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<bool&gt; True if a screen chooser (view or edit) is configured for this Custom Object.

<a id=“SuperOffice_WebApi_Agents_CustomObjectAgent_SaveCustomObjectAsync_System_String_SuperOffice_WebApi_Data_CustomObject_SuperOffice_WebApi_RequestOptions_”></a> SaveCustomObjectAsync(string, CustomObject, RequestOptions)

Saves a Custom Object row. If the row has a primary key set it will be updated, otherwise a new row is inserted.

Parameters

definitionName string Database table name of the Custom Object Definition, e.g. ‘y_equipment’. row CustomObject The Custom Object row to save. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<CustomObject&gt; The saved Custom Object row, with any server-assigned values (e.g. primary key) filled in.