Class EntityUdefHelper
Generic Udef helper class. EntityUdefHelper can read udef fields for entities. The constructor takes to TableRowBase instances, of type UdxxxSmallRow and UdxxxLargeRow, where xxx can be Contact, Sale, Project, Person
Inherited Members
Namespace: SuperOffice.CRM.Entities
Assembly: SoDataBase.dll
Syntax
public sealed class EntityUdefHelper : UdefValueHelper
Examples
Contact c = Contact.GetFromIdxContactId(3);
string s = c.UdefHelper.GetValue("SuperOffice:1") as string;
string s = c.UdefHelper["SuperOffice:1") as string;
c.UdefHelper.SetValue("SuperOffice:1", "foobar");
Constructors
EntityUdefHelper(IEntityUdefHelperContainer)
Constructor for the class that takes reference to a IEntityUdefHelperContainer as an argument.
Declaration
public EntityUdefHelper(IEntityUdefHelperContainer container)
Parameters
| Type | Name | Description |
|---|---|---|
| IEntityUdefHelperContainer | container | Reference to object holding the actuall UdXXYY rows, where XX is name of holder of the userdefined fields and YY is Small and Large. |
See Also
Properties
DisplayTextSuffix
The name suffix for pseudo-fields that contain the display name for a udef field that refers to a list. For each such field NN, there will be a field NN + DisplaySuffix that contains the text corresponding to the current value of NN. The pseudo-field is not updatable, but will be updated whevener the parent field is set.
Declaration
public static string DisplayTextSuffix { get; }
Property Value
| Type | Description |
|---|---|
| string |
See Also
DisplayTooltipSuffix
The name suffix for pseudo-fields that contain the display tooltip text for a udef field that refers to a list. For each such field NN, there will be a field NN + DisplayTooltip that contains the tooltip corresponding to the current value of NN. The pseudo-field is not updatable, but will be updated whenever the parent field is set.
Declaration
public static string DisplayTooltipSuffix { get; }
Property Value
| Type | Description |
|---|---|
| string |
See Also
Methods
ConvertDbTypeToString(string, object)
Utility function for converting a udef STORAGE value with its definition into a string.
Declaration
public string ConvertDbTypeToString(string progId, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | progId | ProgId of field to be converted |
| object | value | STORAGE value (that is, int or string) to be converted |
Returns
| Type | Description |
|---|---|
| string | Udef value as string; all formats are according to the InvariantInfo culture. |
Remarks
String values created in this way will be correctly parsed by the methods that set udef values, for instance by doing
con.Udef["MyFieldProgid"] = someStringValue;
The from string conversion works for all udef data types. Note that all date and number formats must use the InvariantInfo culture!
See Also
ConvertSpecificTypeToString(string, object)
Utility function for converting a udef CLR value with its definition into a string.
Declaration
public string ConvertSpecificTypeToString(string progId, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | progId | ProgId of field to be converted |
| object | value | CLR value (that is, DateTime, int, bool etc) to be converted |
Returns
| Type | Description |
|---|---|
| string | Udef value as string; all formats are according to the InvariantInfo culture. |
Remarks
String values created in this way will be correctly parsed by the methods that set udef values, for instance by doing
con.Udef["MyFieldProgid"] = someStringValue;
The from string conversion works for all udef data types. Note that all date and number formats must use the InvariantInfo culture!
See Also
CopyToAsync(EntityUdefHelper)
Set all the values from the current udef helper on the other udef helper.
Declaration
public Task CopyToAsync(EntityUdefHelper otherUdefHelper)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityUdefHelper | otherUdefHelper | The other udef helper to set the values on. |
Returns
| Type | Description |
|---|---|
| Task |
See Also
GetFieldRight(string)
Get a FieldRight for the udef value.
Declaration
public FieldRight GetFieldRight(string progId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | progId | progId is a string defined as this: [identifier string].[udefidentity int] |
Returns
| Type | Description |
|---|---|
| FieldRight | Permissions on the field. |
See Also
GetProgIdFromFieldLabel(string)
Returns the prog-id for a given field-label. Useful if you don't know the prog-id. Note that field-labels are fuzzy matches, and may give you a different field than the one you are expecting.
Declaration
public string GetProgIdFromFieldLabel(string fieldLabel)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fieldLabel | The label of the field as seen in the GUI |
Returns
| Type | Description |
|---|---|
| string | The unique prog.id (e.g. "SuperOffice:3") of the field, or null if no match found. |
See Also
GetProgIdsAsync()
A list of all the prog.id names for the udef fields on this object.
Declaration
public Task<List<string>> GetProgIdsAsync()
Returns
| Type | Description |
|---|---|
| Task<List<string>> |
Remarks
You can use the prog.id names with GetValue(string) and SetValueAsync(string, object) to update the value stored in the field.
Note that the prog.id name is different from the label of the udef field. The Label is shown to the user, while the prog.id is not shown - it is used as a way of identifying a field programmatically. A typical prog.id might be "SuperOffice:7".See Also
GetValue(string)
Get udef value using the unique prog.id name of the field.
Declaration
public object GetValue(string progId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | progId | progId is a string identifier on the field. It defaults to "SuperOffice:[udefidentity int]" but can be set to any unique string. |
Returns
| Type | Description |
|---|---|
| object | The value asked for as an object |
Exceptions
| Type | Condition |
|---|---|
| SoIllegalOperationException | Thrown if the incoming data type cannot be converted to the underlying storage type |
See Also
SetDefaultAsync(string)
Set the value of the given field to be the default value specified in the fields' definition, if any. Also update display text and tooltip if relevant.
Declaration
public Task SetDefaultAsync(string progId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | progId | Field identification; if no such field exists nothing happens |
Returns
| Type | Description |
|---|---|
| Task |
See Also
SetDefaultsAsync()
Set the values of ALL defined fields to their default values. Note that slots in the udefSmall and udefLarge tables that have not been assigned to any field are NOT modified. Also update display texts and tooltips as relevant.
Declaration
public Task SetDefaultsAsync()
Returns
| Type | Description |
|---|---|
| Task |
See Also
SetValueAsync(string, object)
Set udef value. The incoming data type must either correspond to the database storage type, or be convertible to it. strings are accepted provided they have the proper format. Number and date strings must be formatted using InvariantInfo from System.Globalization.
Declaration
public Task SetValueAsync(string progId, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | progId | progId is a string defined as this: [identifier string].[udefidentity int] |
| object | value |
Returns
| Type | Description |
|---|---|
| Task |
See Also
TrySetValueAsync(string, object)
Generic Udef helper class. EntityUdefHelper can read udef fields for entities. The constructor takes to TableRowBase instances, of type UdxxxSmallRow and UdxxxLargeRow, where xxx can be Contact, Sale, Project, Person
Declaration
public Task<bool> TrySetValueAsync(string progId, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | progId | |
| object | value |
Returns
| Type | Description |
|---|---|
| Task<bool> |
Examples
Contact c = Contact.GetFromIdxContactId(3);
string s = c.UdefHelper.GetValue("SuperOffice:1") as string;
string s = c.UdefHelper["SuperOffice:1") as string;
c.UdefHelper.SetValue("SuperOffice:1", "foobar");
See Also
Events
OnUdefValueChange
Subscribe or unsubscribe to event raised every time the value of an udef field is modified.
Declaration
public event EntityUdefHelper.UdefValueChange OnUdefValueChange
Event Type
| Type | Description |
|---|---|
| EntityUdefHelper.UdefValueChange |