To show a user-defined field in the client, it must first be published.
Steps
The following REST code snippets use plain http requests to demonstrate how to perform the operation. The WebApi code snippet demonstrates how to perform the same operation using our nuget package SuperOffice.WebApi. All examples depend on the udefFieldType enum type to define what the data type of the user-defined field should be.Create user-defined field of type Number
These examples demonstrate how to create a Number user-defined field. First, a request is sent to obtain the default user-defined field structure, including calculated positioning in the client. Then field values are updated to reflect field text, tooltip, whether it should be indexed, or be mandatory.- RESTful REST API
- HTTP RPC Agent API
- CRMScript API
-
First get the JSON structure that represents a user-defined field. This is a POST request.
Yes, it is unconventional to use a POST request to get an entity structure, however, this is specific to user-defined fields.
-
Update the relevant fields. Change FieldLabel, ShortLabel to update what text is shown in the client.
-
Save the user-defined field. This is a PUT request.
Yes, it is unconventional to use a PUT request to save, however, this is specific to user-defined fields.
The PUT request accepts an array of user-defined fields, so more than one could be updated or saved at the same time. Existing user-defined fields not in the array will not be deleted.
The response will contain all of the user-defined fields for this entity, but now the new user-defined field UDefFieldId property will contain a identity value.
-
Make sure the Contact user-defined fields are not currently being updated.
Only if the response is False, proceed to publish and complete the delete operation.
-
Publish the user-defined field.
A Publish request creates a new version of all user-defined fields for the entity. Therefore, all user-defined fields will have updated UdefFieldId values.
-
Finally issue the RebuildUdefDeltas request to force the field to appear in the UI.
Use the HTTP RPC Agent endpoint as there is no RESTful equivalent.
Depending on the user-case it might be a good idea to flush caches.
User-Defined Field Lists
To create a user-defined field based on a list, create it withudefFieldType List.
User-defined lists
For user-defined lists, set the ListTableId and UDListDefinitionId property values accordingly.Built-in lists
For Build in Lists. for example the Business list entity, only set theListTableId property. You can get the ListTableId property from the MDOProviders documentation page. Alternatively, you can query for all using the dynamic archive provider.
Request:
- Restful REST
- HTTP RPC Agent
- SuperOffice.WebApi
udlistdefinition.listTableId value.