BrowseDialog setting intial value


Author
Message
Ian Johnston
Ian Johnston
StrataFrame User (221 reputation)StrataFrame User (221 reputation)StrataFrame User (221 reputation)StrataFrame User (221 reputation)StrataFrame User (221 reputation)StrataFrame User (221 reputation)StrataFrame User (221 reputation)StrataFrame User (221 reputation)StrataFrame User (221 reputation)
Group: StrataFrame Users
Posts: 77, Visits: 470
Is there a way to set the intial value of a search field at runtime i.e filter a date field based on today's date using greater than or equal to?
Replies
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Ian,

The error means that there is a duplicate field in the Search field collection and this is most likely to be when using a Date field for searching since we most use Greater than and Less than conditions.

this.browseDialog1.SearchFields[3].InitialValue = dateTimePickerBegin.Value.ToShortDateString();
this.browseDialog1.SearchFields[4].InitialValue = dateTimePickerEnd.Value.ToShortDateString();



To fix this, modify the BD and in the Search Field Criteria for the Ending Date field, enter a Unique Key to make it unique.  By default SF will automatically enter the field name, but you can and must change it to a unique one in this case.

Also, in general I prefer to use the Browse Dialog events to handle this situation problematically, so instead of having all the code in the button1, I would enter your code in the InitializedSerachFields events and instead of using index for the field name I would use the business object FieldNames enumeration so if in the future a field name changes at least my application will generate a compilation exception so I can fix it and also it looks better in code to see which fields are actually being initialized.  Here is a VB sample of this event:

Private Sub ServiceCallsBD_InitializeSearchFields(ByVal sender As System.ObjectByVal e As System.EventArgsHandles ServiceCallsBD.InitializeSearchFields
        With Me.ServiceCallsBD
            .SearchFields(bizServiceCalls.bizServiceCallsFieldNames.CallDateTime.ToString).InitialValue = Now.ToString
            .SearchFields(bizServiceCalls.bizServiceCallsFieldNames.Notes.ToString).InitialValue = "My nice note"""
        End With
End Sub


Edhy Rijo

Edited 14 Years Ago by Edhy Rijo
Ian Johnston
Ian Johnston
StrataFrame User (221 reputation)StrataFrame User (221 reputation)StrataFrame User (221 reputation)StrataFrame User (221 reputation)StrataFrame User (221 reputation)StrataFrame User (221 reputation)StrataFrame User (221 reputation)StrataFrame User (221 reputation)StrataFrame User (221 reputation)
Group: StrataFrame Users
Posts: 77, Visits: 470
Thanks that fixed it

Ian
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
You are welcome Ian.

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Ian Johnston - 14 Years Ago
Ivan George Borges - 14 Years Ago
Ian Johnston - 14 Years Ago
Edhy Rijo - 14 Years Ago
                     Thanks that fixed it Ian
Ian Johnston - 14 Years Ago
                         You are welcome Ian.
Edhy Rijo - 14 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search