Show / Hide Table of Contents

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

Inheritance
Object
UdefValueHelper
EntityUdefHelper
Inherited Members
UdefValueHelper.ConvertDbTypeToString(UDefFieldRow, Object)
UdefValueHelper.ConvertSpecificTypeToString(UDefFieldRow, Object)
UdefValueHelper.ConvertDbToSpecificType(UDefFieldRow, Object)
UdefValueHelper.ConvertSpecificToDbType(UDefFieldRow, Object)
UdefValueHelper.ConvertDecimalToDbType(UDefFieldRow, Object)
UdefValueHelper.ConvertListToDbType(UDefFieldRow, Object)
UdefValueHelper.ConvertCheckboxToDbType(UDefFieldRow, Object)
UdefValueHelper.ConvertUnlimitedDateToDbType(UDefFieldRow, Object)
UdefValueHelper.ConvertDateToDbType(UDefFieldRow, Object)
UdefValueHelper.ConvertNumberToDbType(UDefFieldRow, Object)
UdefValueHelper.ErrorIdentification(UDefFieldRow)
UdefValueHelper.TimeTLocal2DateTime(Int32)
UdefValueHelper.DateTime2TimeTLocal(DateTime)
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
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.

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

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

Item[String]

Set or get udef value. During set, 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 object this[string progId] { get; set; }
Parameters
Type Name Description
String progId

progId is a string defined as this: [identifier string].[udefidentity int]

Property Value
Type Description
Object

The value asked for as an object (e.g. Int32, string, etc)

Remarks

Same as the GetValue() method.

Exceptions
Type Condition
SoIllegalOperationException

Thrown if the incoming data type cannot be converted to the underlying storage type

ProgIds

A list of all the prog.id names for the udef fields on this object.

Declaration
public List<string> ProgIds { get; }
Property Value
Type Description
List<String>
Remarks

You can use the prog.id names with GetValue(String) and SetValue(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".

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!

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!

CopyTo(EntityUdefHelper)

Set all the values from the current udef helper on the other udef helper.

Declaration
public void CopyTo(EntityUdefHelper otherUdefHelper)
Parameters
Type Name Description
EntityUdefHelper otherUdefHelper

The other udef helper to set the values on.

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.

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
UDefFieldCache
UDefFieldRow

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

SetDefault(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 void SetDefault(string progId)
Parameters
Type Name Description
String progId

Field identification; if no such field exists nothing happens

SetDefaults()

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 void SetDefaults()

SetValue(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 void SetValue(string progId, object value)
Parameters
Type Name Description
String progId

progId is a string defined as this: [identifier string].[udefidentity int]

Object value

TrySetValue(String, Object)

Declaration
public bool TrySetValue(string progId, object value)
Parameters
Type Name Description
String progId
Object value
Returns
Type Description
Boolean

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

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)

See Also

Contact
Person
UDefFieldCache
UDefFieldRow
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top