Attempting to read a domain value and set it as a default option for a field.

343
0
03-28-2019 07:41 AM
MatthewWard
New Contributor

Hi there! I am using VB.NET and Visual Studio 2017. I have three fields, MOTTLES, RCL, AND SEEPAGE, that all have domains with two values in them - absent and present. I want to read these values, and set fields that correspond to these categories as a default 'absent'. I've had some luck with setting a numerical default value, but am unsure how to refer to coded values. This is within my Public Sub New:

If IsNewRecord Then
   Me.SAMPLE_ID = Constants.UserCollectionCount.sampleName

   If OBSERVATION_TYPE = enumTillTypes.Geochem Then
      A_BOUNDARY_UP = 0

I most recently created a property AllMottles to read through the values of the domain and check for a specific value:

Dim temp As IReadOnlyList(Of CodedValue) = MyBase.GetAllCodeValues(Constants.COL_TILL_MOTTLES)
Dim returnValue As New List(Of CodedValue)(temp.Count)
Dim mottlescode As String
If OBSERVATION_TYPE = enumTillTypes.Geochem Then
   For Each entry As CodedValue In temp
   mottlescode = entry.Code.ToString
      If mottlescode.StartsWith("A") Then
         returnValue.Add(entry)
      End If
   Next

   Else

But again, am not sure how to refer to the codedvalue itself. 

Help would be great!

0 Kudos
0 Replies