Custom Grid on a BPM Data Form?

Anyone add a grid to a BPM data form? I’m trying to add a grid to a Quote entry BPM Form and have it populate via a BAQ. I’ve done similar on normal menu launched forms and used @josecgomez awesome tutorial Efficiently Adding Column to DataGrid - #5 by josecgomez

The challenge here is by default the form doesn’t have access to the quote data. So I passed the quotenum via BPMData “Number20” field. It displays on the BPM form now. So I’m trying to use that as the value to run the BAQ to populate the grid. We have a UD field “SLID” that links quotes as related to the same project. The ask is to display all quotes with the same SLID when creating a new related quote.

I’m trying to piggyback on some existing custom code that retrieves the BPM data variables.
As you can see, I got the quotenum to display that I want to use to populate the grid but no joy on getting the grid to work. Pretty sure I’m messing up in the EpiViewNotifcation section of code.

Current code:

using Ice.Lib.Broadcast;

public class Script
{
	BAQDataView baqRelatedQTview;  
	string relQT;
	string pubBinding;
	IPublisher pub;

	public void InitializeCustomCode()
	{
		CreateRelatedQTsBAQView();
	}

	public void CreateRelatedQTsBAQView()
	{
		baqRelatedQTview = new BAQDataView("RelatedQTs");
		oTrans.Add("gridRelatedQTs_RS", baqRelatedQTview);
	}

	private void edvBPMData_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
	{
		if( edv != null )
		{
			if( edv.dataView[edv.Row]["Number20"] != null )
			{
				relQT = Convert.ToString(edv.dataView[edv.Row]["Number20"]); 
				pubBinding = relQT;
				baqRelatedQTview.SubscribeToPublisher(pub.PublishName, relQT);
			}	
		}

Ok still working on this and a bit closer. It’s not refreshing the grid on form load but I think I know how to fix that and I need to switch field I’m using to send to the BAQ as the filter.

Ok, there is no FormLoad event in the Wizard so… hmm. But the BAQ subscription is working just not populating on loading of the form until the “SLID” field is changed.

You can always try just creating it (use the syntax from another form’s wizard generated code). Throw a message box in it to see that it is actually being called.

May try that, was thinking of adding a button to trigger the refresh of the grid like some other forms have.

Does customizing a BPM Form have two aspects like a dashboard? You do some of the “customization” in the designer, and other customization to the deployed form.

From the dashboard analogy, you can customize a tracker pane, while in the developer mode in Dashboard builder. And other customizations are done to the deployed dashboard by entering developer mode, launching the deployed dashboard, then entering Customization mode.

Sort of, the on screen bits are done using the BPM Form Designer. Custom code won’t seem to save that way so I have to use Customization Maintenance then Actions - “Show Custom Data” to edit code. ¯_(ツ)_/¯

1 Like

I could never get the grid to populate on the BPM Form load but I’m closer to getting the button to work thanks to @josecgomez coming to the rescue again: Refresh grid not working 10.2.600 - #2 by josecgomez However it’s not using the field binding so pulling all records from the BAQ.

How do I modify it to use the field binding? I tried reassigning the pubBinding but that didn’t help. pubBinding & pub are assigned in InitializeCustomCode so I didn’t expect this would work. I’ve been unable to use either in MethodInfo though.

public class Script
{
   string pubBinding;
   IPublisher pub; 

	private void epiButtonC1_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **	
		if(pub==null)
		{
			oTrans.PublishColumnChange(pubBinding, "MyCustomPublish");
			pub = oTrans.GetPublisher(pubBinding);
		}		
		if(pub != null)
		{
			pubBinding = "BPMData.ShortChar02";
			pub = oTrans.GetPublisher(pubBinding);
			MethodInfo mi = baqRelatedQTview.GetType().GetMethod("InvokeExecute", BindingFlags.Public | BindingFlags.NonPublic);
			mi.Invoke(baqRelatedQTview, new object[]{true});
		}
	}

}

Ok got it working with some mojo from @hmwillett

Basically, it’s a trick. The form needed to be refresh to display the grid data. So to trigger the refresh the trick was to bind the BAQ View to another data column not passed by the BPM code. Without the bound field changing the oTrans.NotifyAll() wasn’t firing as there was no change to the data.

using Ice.Lib.Broadcast; 

public class Script
{
	EpiDataView edv;
	private EpiDataView edvCallContextBpmData;
	private EpiDataView edvBPMData;
	BAQDataView baqRelatedQTs;
	string pubBinding;
	IPublisher pub;

	public void InitializeCustomCode()
	{
		this.edvCallContextBpmData = ((EpiDataView)(this.oTrans.EpiDataViews["CallContextBpmData"]));
		this.okBTN = (EpiButton)csm.GetNativeControlReference("bc01f486-deca-43a3-a2ae-7209307afee1");

		edv = ((EpiDataView)(this.oTrans.EpiDataViews["BPMData"]));
		this.edvBPMData = ((EpiDataView)(this.oTrans.EpiDataViews["BPMData"]));
		this.edvBPMData.EpiViewNotification += new EpiViewNotification(this.edvBPMData_EpiViewNotification);
		CreateRelatedQTsView();

	public void CreateRelatedQTsView()
	{
		baqRelatedQTs = new BAQDataView("RelatedQTs"); 
		oTrans.Add("RelatedQTsBAQ", baqRelatedQTs);

		pubBinding = "BPMData.ShortChar09";
 		pub = oTrans.GetPublisher(pubBinding);

		if (pub == null)
		{
			oTrans.PublishColumnChange(pubBinding, "MyCustomPublish");
			pub = oTrans.GetPublisher(pubBinding);
		}
		if (pub != null)
			baqRelatedQTs.SubscribeToPublisher(pub.PublishName, "QuoteHed_SpotlightID_c"); 
	}

	private void IP_QuotePID_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code

		edv = oTrans.Factory("BPMData");
		edv.dataView[edv.Row].BeginEdit();
		edv.dataView[edv.Row]["ShortChar09"] = edv.dataView[edv.Row]["ShortChar10"].ToString();
		edv.dataView[edv.Row].EndEdit();
		oTrans.NotifyAll();
	}
}
1 Like