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. |
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
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 |
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
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 |
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
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.
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");
Exceptions
Type | Condition |
---|---|
SoIllegalOperationException | Thrown if the incoming data type cannot be converted to the underlying storage type |
See Also
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".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
Methods
add_OnUdefValueChange(EntityUdefHelper.UdefValueChange)
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 void add_OnUdefValueChange(EntityUdefHelper.UdefValueChange value)
Parameters
Type | Name | Description |
---|---|---|
EntityUdefHelper.UdefValueChange | value |
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
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!
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
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!
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
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. |
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
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. |
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
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. |
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
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 |
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");
Exceptions
Type | Condition |
---|---|
SoIllegalOperationException | Thrown if the incoming data type cannot be converted to the underlying storage type |
See Also
remove_OnUdefValueChange(EntityUdefHelper.UdefValueChange)
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 void remove_OnUdefValueChange(EntityUdefHelper.UdefValueChange value)
Parameters
Type | Name | Description |
---|---|---|
EntityUdefHelper.UdefValueChange | value |
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
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 |
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
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()
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
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 |
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
TrySetValue(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 bool TrySetValue(string progId, object value)
Parameters
Type | Name | Description |
---|---|---|
String | progId | |
Object | value |
Returns
Type | Description |
---|---|
Boolean |
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 |
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");