Announcement

As of April 17, 2018, this site is now in read-only mode. To start new Blackbaud Developer’s discussions, you will find Developer Discussions in the Blackbaud CRM Community.

To post or respond to Blackbaud Community discussions, you will have to login using a www.blackbaud.com login. Learn how to login here. If you have questions or need assistance, please email community@blackbaud.com.

1.7k questions

3.2k answers

401 users

Categories

1.7k questions

3.2k answers

401 users

I have a custom tribute add form that serves as an intermediary between a web form and CRM. The purpose is to display tribute pertinent information collected online so that our users can search for existing tributes to make the determination if a new tribute is needed. If a new tribute needs to be created, the process is completely straight forward: new tribute is created, tributee is selected from a search list, and acknowledgees/letters are inserted manually into a collection field. The problem comes when selecting an existing tribute. I have created a value changed method for the Tribute ID where, once the value is changed, I'm trying to call a datalist to load the acknowledgee/letter collection field, and a simple data list to load the tributee from the existing tribute. The code is as follows:

Private Sub _tributeID_ValueChanged(ByVal sender As Object, ByVal e As Blackbaud.AppFx.UIModeling.Core.ValueChangedEventArgs) Handles _tributeid.ValueChanged
    Me.TRIBUTEACKNOWLEDGEE.Value.Clear()
    Me.TRIBUTEE.Value = Nothing

    Dim trib = _tributeid.Value

    ResetTributee(trib)
    ResetTributeAcknowledgee(trib)

End Sub

Private Sub ResetTributeAcknowledgee(ByVal trib As Guid)
    Dim AckReq As New DataListLoadRequest
    AckReq.DataListID = New Guid("7c8b3f7c-bb7e-455c-a087-2d975a35b8ba")
    AckReq.Parameters = New DataFormItem
    AckReq.Parameters.SetValue("TRIBUTEID", trib)

    Dim AckSvc = New AppFxWebService(Me.GetRequestContext())
    Dim AckReply = AckSvc.DataListLoad(AckReq)

    If AckReply IsNot Nothing Then
        For Each item In AckReply.Rows
            Dim TribAck = Me.TRIBUTEACKNOWLEDGEE.Value.AddNew()
            TribAck.ID.Value = New Guid(item.Values(0))
            TribAck.CONSTITUENTID.Value = New Guid(item.Values(2))
            TribAck.TRIBUTELETTERCODEID.Value = New Guid(item.Values(5))
        Next
    End If
End Sub

Private Sub ResetTributee(ByVal trib As Guid)
    Dim TribReq As New SimpleDataListLoadRequest
    TribReq.DataListID = New Guid("b84fd53f-a5dd-4012-8557-ecd49aced2f9")
    TribReq.Parameters = New DataFormItem
    TribReq.Parameters.SetValue("TRIBUTEID", trib)

    Dim TribSvc = New AppFxWebService(Me.GetRequestContext())
    Dim TribReply = TribSvc.SimpleDataListLoad(TribReq)
    If TribReply IsNot Nothing Then
        For Each item In TribReply.Rows
            Me.TRIBUTEE.Value = New Guid(item.Value)
        Next
    End If
End Sub

When I build this, then try to run through the process, I get the error: "You must specify a valid Context Record ID." Per the data list I'm trying to call, the ID field has an index of 0, so I was under the impression that's what I need to do when using a DataListLoadRequest. I removed the ResetTributeAcknowledgee() sub altogether to see if the error would go away. It did, however, the ResetTributee() doesn't seem to be working either leading me to believe I really have no idea what to do. Can anyone let me know what is wrong with this code? Thanks.

asked by davidkoleno (188 points)
edited by danielcooke

1 Answer

 
Best answer

The context is not a parameter to the datalist and should be set through AckReq.ContextRecordID

As far as the simple datalist call I'm not entirely sure what you are trying to accomplish - is Me.TRIBUTEE already a simple datalist field or are you trying to populate a single value? Currently you are iterating over a collection of rows and overwriting on each subsequent row.

answered by danielcooke (3.5k points)
selected by davidkoleno
Awesome! AckReq.ContextRecordID worked great. As for the Me.TRIBUTEE field, it is not a collection. I am trying to populate a single value. I couldn't think of another way to do it without executing SQL directly in my script. I figured since Tribute -> Tributee is a one-to-one relationship, this would be a pretty simple way to do it. Is there any easier way? Sorry, I'm really new to this stuff and trying really hard to pick it up!
I would update it to a view data form where the context of that form is the tributee.  You can have that view form return the single value or if later it is one-to-many return a collection of values.
I did some additional testing and learned that the value was being passed in. This is a guid field, but it is also a searchlist field. I realized that on the Acknowledgee/Letter collection field, the Letter code was visible because it is a code table field and hence can handle the translation from value to label. However, the Acknowledgee field is also blank, is also a guid field, and also a search list field. That the challenge for me and my noob skills. How do I pass a guid into a search list field, invoke the search to take place, and automatically pick the match? I found some methods for InvokeSearch, but documentation on how to work with it is sparse and I'm unsure how to work it into my current code structure. I'm initiating a new topic since I know this technically is a different topic.
...