Get record(s) using customization or bpm

Hi all,
I have a customized UD102 screen. After the push of a button on the screen (which forces an update) I want to fetch (one or more, depends on the keys I pass) UD102 records, without (!) using the search button .
So this either needs to be done in the customization or in the bpm.
Does anyone has a hint to do this?

Thanks,
John

That’s a pretty open ended request. There are lots of ways to get records, both in BPMs and in customization. What you want to do with those records will determine which is the better option. Are you just looking at displaying them in a grid or something? What do you mean by “fetch”?

I mean to get them in order to display and update them (just as if I selected the records using the search button).

John

So what are the exact steps that you want to happen? Like:

  1. Launch UD102 Entry form (assuming it comes up blank - no records preloaded)
  2. Create a new record and enter values (Say Key1 - Key3).
  3. Click a custom button that will save the current record. Then load records based on the values of Key1 - Key3. Like if you had:
    a. Pressed the Search button
    b. manually selected the UD102 records that match your criteria for Key1 - Key3
    c. clicked OK

That sound right?

Hi Calvin,
Yes, exactly as you describe. I may alter the values of key1-key3 to get more or less records.

So for that, I’m pretty sure you’ll need to do it in a customization. A BPM for the most part is only going to get the record for the row (record) that you are on, and you can’t add to the dataview from there. So you have to probably use a getrows and add them to your dataview. I’ve never actually done that, so I don’t have the code for it, but that’s how I would attack this. You’ll have to probably handle clearing out the rest of the dataview as well to make sure you only have what you intend in the view.

This is what I have so far (I am misusing the code generated by the wizard) :

 private void CallUD102AdapterGetRowsMethod(Ice.Lib.Searches.SearchOptions opts, out bool morePages)
	{
		morePages = false;
		try
		{
			// Declare and Initialize EpiDataView Variables
			// Declare and create an instance of the Adapter.
			UD102Adapter adapterUD102 = new UD102Adapter(this.oTrans);
			adapterUD102.BOConnect();

			// Declare and Initialize Variables
			// TODO: You may need to replace the default initialization with valid values as required for the BL method call.

			// Call Adapter method
			System.Data.DataSet dsUD102 = adapterUD102.GetRows(opts, out morePages);

			// Cleanup Adapter Reference
			adapterUD102.Dispose();

		} catch (System.Exception ex)
		{
			ExceptionBox.Show(ex);
		}
	}

I have filled the whereclause and tested (I do get data from the getrows). But now I am stuck : how do I fill the UD102 dataview with the information in the dataset ? I’m quite sure this is simple, but I just do not see it yet.

You could use a post proc on BPM on UD102.Update(), that calls UD102.GetRows().

image

All you have to do is set the WhereClause parameters in the BO widget.

This will fire whenever a record is saved. One down side, it will leave the previous records in the form, but you could probably clear them with a minor UI customization.

Hi Calvin, thanks for the advice. This does look a little better. Using the getrows in the post update I do get records.
I tried to clear the data in the screen before the update (in the customization) using :
oTrans. Clear() --> this shows the previous data AND the records from the getrows.
oTrans. ClearDataSet() --> this clears the whole screen and does not show anything at all.

Any advice?
By the way : all records do show on the treeview on the left, but not in the dropdown on top of the screen (there only the previous record is shown).

Hmmm … now that I think about this, there’s a chicken and the egg condition. If you clear the for first, then there’s no record to use for setting the whereClause. And any if you clear it after getting the new records, then they’ll clear too.

Maybe you count the rows in your data set and only add rows if there is only one. That would require you to clear before you searched for another one. (or clear on search)

If you get stuck using the directive approach or are curious about another approach…
I would leverage the adapter for this, in the customization.

            UD102Adapter adapter = (UD102Adapter)oTrans_adapter;
		    //add more keys to clause if need be. 	
            string whereClause = String.Format("Key1 = '{0}'", key1);
   			System.Collections.Hashtable whereClauses = new System.Collections.Hashtable(1);
			whereClauses.Add("UD102", whereClause);

			// Call the adapter search.
			SearchOptions searchOptions = SearchOptions.CreateRuntimeSearch(whereClauses, DataSetMode.RowsDataSet);
			adapter.InvokeSearch(searchOptions);

			if ((adapter.UD102Data.UD102.Rows.Count > 0))
			{
				this.edvUD102.Row = 0;
			} else
			{
				this.edvUD102.Row = -1;
			}

			// Notify that data was updated.
			this.edvUD102.Notify(new EpiNotifyArgs(this.oTrans, this.edvUD102.Row, this.edvUD102.Column));
2 Likes

Yeah, the customization is probably the way to go. Especially since it involves the UI.

Sorry if I led you down a wrong path.

Hello all,
Thank you all for thinking along.
The solution using the customization seems to be the way to go.

Thanks again,
John