Set default values on an OOB search list (defaulting to form field values, not hard-coded)

I know you can set default values on a data form in design mode using the “Default Values” property. I also know you can set default values on a search list in design mode using “Form Field Overrides”. My issue is Form Field Overrides only allows hard-coded values and does not allow form field values from the data form to be used as default values on the search list fields. For a simple example, I have a data form, Test Data Form, that has a last name field on it. Test Data Form also has a Constituent Search (searchlist) field on it. When I click Constituent Search, I'd like to default the Last Name field on the search form to the last name field value from Test Data Form. Support has confirmed this cannot be done in design mode. It is unclear to me if it's even possible at all. It was mentioned that I may be able to use some CLR to do this, but it is an OOB search list that I am opening, so I'm not sure what to try. Has anyone done anything like this?

Comments

  • @Kevin Hamling

    You can do this using a UI Model on your custom form. Then you can handle the ValueChanged event handler on the last name field, and when it changes update the SearchFieldOverrides on the search list.

    It would look something like this, depending on your field names:

    Private Sub _lastname_ValueChanged(ByVal sender As Object, ByVal e As UIModeling.Core.ValueChangedEventArgs) Handles _lastname.ValueChanged

    CONSTITUENT.SearchFieldOverrides.Add(New FieldOverride() With { .FieldId = "LASTNAME", .DefaultValueText = LASTNAME.Value})

    End Sub

  • @Nick McGinnis
    Thank you! I was looking for CONSTITUENT.FormFieldOverrides, like how it is in the xml on the form field. SearchFieldOverrides in the UIModel is what I overlooked and exactly what I needed.

  • @Nick McGinnis
    Again, thanks for the help. That was what I needed to get the values into a search list. In the same code, I have an AddDataForms section that gives the ability for the user to open the add constituent data forms. Do you know if it is also possible within my UIModel to set default values on these add data forms in a similar way? Normally, I would use DefaultValues on a data form in design mode along with expression view forms (page property), but since I cannot access the properties (DefaultValues) of these 4 add forms in design mode, I think I need to default them in the UIModel. I am trying to figure it out and appreciate any help.

    <FormFields>
    <FormField Caption="Last Name" FieldID="KEYNAME" ReadOnly="true" />
    <FormField Caption="First Name" FieldID="FIRSTNAME" ReadOnly="true" />
    <FormField Caption="TItle Name" FieldID="TITLECODEID" Hidden="true" />
    <FormField Caption="Suffix" FieldID="SUFFIXCODEID" Hidden="true" />
    <FormField Caption="Address" FieldID="ADDRESSBLOCK" Multiline="true" ReadOnly="true" />
    <FormField Caption="Address Begins With" FieldID="ADDRESS_FIRST_WORD" Hidden="true" />
    <FormField Caption="Zip" FieldID="ZIP" ReadOnly="true" />
    <FormField FieldID="CONSTITUENTID" Caption="Constituent" DataType="Guid" Required="true">
    <SearchList SearchListID="23c5c603-d7d8-4106-aecc-65392b563887">
    <FormFieldOverrides>
    <FormFieldOverride DefaultValueText="false" FieldID="ONLYPRIMARYADDRESS" />
    </FormFieldOverrides>
    <AddDataForms>
    <AddDataForm Caption="Individual" ID="1f9671b3-6740-447c-ad15-ef2718c0e43a" />
    <AddDataForm ID="d846a816-46c7-470e-9ad0-973b2730e836" Caption="Household" CaptionResourceKey="$$household" />
    <AddDataForm ID="f0f6426a-fccd-48bb-846b-eb3d1a4a0ed4" Caption="Group" CaptionResourceKey="$$group" />
    <AddDataForm ID="ca3ed110-a5f0-4b5b-8eb7-0616e0a82e8e" Caption="Organization" CaptionResourceKey="$$organization" />
    </AddDataForms>
    </SearchList>
    </FormField>
    </FormFields>

  • @Kevin Hamling
    Glad I was able to help. I took a look at the UI model and it doesn't seem you can get to the DefaultValues for a Search List Add form. You can get to CONSTITUENT.SearchListAddForms, but the SearchListAddForm class only has Caption, ContextIdDefintion, and DataFormInstanceId. So unfortunately I do not think that is going to be possible

  • @Nick McGinnis
    Thank you for taking a look at it. That's the same thing I was seeing and just wanted to make sure I didn't miss something obvious.

Categories