Update a textfield in batch row based on the selected value of a drop down list within the same row

I am trying to update the value in a text field in a batch, based on the selection made from a drop-down list, which is using a code table.


I have TSQL code in my Add and Edit specs to correctly update the text field depending upon the value in my drop-down list. This works fine, but of course, the value in my text field does not update when the drop-down list is changed, only when the batch is saved, closed, and re-opened..


Through a UIModel class, I am trying to detect when the drop-down list has changed (or when the list or row loses focus), then I am trying to set the value in another text field within the same row. I've been trying to refresh the control, the row \\ record, or even the whole dataset, but haven't had any luck.


What's the best way to do this? Any recommendations?


Thank you,


Ernie


Comments

  • Ernie,


    The best way to alter behaviors in the batch is through a batch handler. Here is some documentation on how to implement a FieldChangedHandler that allows you to delegate methods to handle different fields changing. Hope this helps!
  • Thanks Nick. I am reading it now.

  • The documentation was extremely helpful, and I am close to having something functioning now. I have a lot working, but two points of failure. I am using this documentation as suggested. Blackbaud - Step By Step: Retrieving Default Data when a Field Changes

    I am able to add and call the field changed handler. This is working.
    Next I create an ID and populate it using the example syntax, if I understand correctly this is expected to be the batch row \\ record ID to be used later.

    Dim ID = DirectCast(GetValueFromFieldID(e.Model, e.Field.Name, Guid.Empty), Guid)

    ID is empty when written this way. Seems like we are asking for the model and field name or the field which called the subprocedure. This is the field we are watching to see if it changed. If I hard code ID to my batch row GUID or if I set my ID = Me.ActiveModel.ContextId the rest of my code executes but still does not work. I am confused as to why the suggested syntax is not firing and I am concerned I have misinterpreted what is needed. Replacing the code suggested in the documentation seems wrong, but its the only way I can get anywhere.


    Next, we inspect the ID to make sure its not empty (it's ok if I hard code it or call Me.ActiveModel.ContextID, otherwise this check fails, the subprocedure returns and we are done.


    If ID.Equals(Guid.Empty) Then Return

    We build a DataFormLoadRequest referencing the form that will (reload data to be used a few lines later. I am using the Edit Form in my batch, and assume it references the LOAD stored procedure defined within. This runs fine. It uses the ID defined above, and I am worried about that variable.


    Next we create a DataFormLoadReply. No problems

    We try to populate the Reply


    reply = Blackbaud.AppFx.Server.DataFormLoad(request, Me.RequestContext)

    This works and returns something. We get all the way to our call to:


    TrySetValuesFromDFI(e.Model, reply.DataFormItem, "MYFORMFIELDNAME", "MYDATAFIELDNAME")

    This executes but does not update my field. Nothing happens.


    I can call TrySetValueForFieldID() all day long with succes, but not TrySetValuesFromDFI.


    No errors, just no change to the desired field.


    Any suggestions?


    Thanks,


    Ernie