I have a custom BAQdv in the Tasklist screen which subscribes to the Epicor Task dv using the SaleRepCode column. This works however, when the EndDate in the screen is changed the BAQdv does not filter out the discarded rows from the Task dv because of the one column key subscription. Is there any away to add another key column to the subscription.
public void CreateTaskListBAQView()
{
// Initialize the BAQDataView by giving it the BAQ name that will be used.
baqViewTaskList = new BAQDataView("MGATaskList-V2");
// This will add the BAQDataView to the form, so we can bind it to the grid. The DataView will be called "CustTrackershipment".
oTrans.Add("MGATaskList",baqViewTaskList);
string pubBinding = "Task.SalesRepCode"; // this is the actual table name from the Task view.
IPublisher pub = oTrans.GetPublisher(pubBinding); // if the publisher exist, then a publisher name will be returned.
// The following code is only needed if the filter field "Customer.CustID" have NOT been published. In this case I am using a standard column.
// Most likely the CustID is published. If this was an uncommon column like a UD field, I would need to check and publish the field. The code in
// place will check for this condition. The purpose of the publisher, is everytime the Customer.CustID is changed, the new value becomes available
// and the BAQ DataView is filtered accordingly. The BAQ DataView will have all the customers in it.
if(pub==null) // if no publisher
{
//MessageBox.Show("if not null".ToString());
oTrans.PublishColumnChange(pubBinding, "MyCustomPublish1"); // publish it
pub = oTrans.GetPublisher(pubBinding); // get a hold of that publisher
}
// MessageBox.Show("before if pub != null".ToString());
if(pub !=null) // if we have that publisher available then we want to subscribe (filter) the BAQDataView to that publisher
// Filter on the Customer_CustNum column in the custom BAQDataView.
baqViewTaskList.SubscribeToPublisher(pub.PublishName, "Task_SalesRepCode"); // this is the actual column name from the BAQ
You should be able to just add additional Publishers, Subscribers and PublishColumnChange’s.
Example:
oTrans.PublishColumnChange("UD100View.Year_c", "UD100YearPub");
oTrans.PublishColumnChange("UD100View.Age_c, "UD100AgePub");
var yearPub = oTrans.GetPublisher("UD100View.Year_c");
var agePub = oTrans.GetPublisher("UD100View.Age_c");
baqViewTaskList.SubscribeToPublisher(yearPub.PublishName, "Calculated_SomeColumnr");
baqViewTaskList.SubscribeToPublisher(agePub.PublishName, "LaborDtl_IndirectCode");
// Keep adding as much as you need - add your EndDate to it.
I was able to do what you suggested using your example. However, the result is not what I expected. Epicor does not combine both publisher like an AND statement. More like the last publish is the one that is used not the first. Very strange. The reason I say this is because, I tried both publishers separately, the SaleRepCode and then the DueDate. The BAQdv has both columns. The problem I am trying resolve:
The TaskList has a SalesRepCode select/search field and default End/DueDate three months in advance of the system date. If I subscribe to the SaleRepCode and then Select a SalesRepCode the BAQdv rows will match to the Taskdv. However, when the End/Due date is changed to an early date, this reduces the Taskdv rows but does not reduce the BAQdv rows. I am not sure why this is? I can only guess that the BAQ is no filtering further by the End/Due Date?
It does do this, there must be something else you are doing incorrectly. Epicor combines both publishers if both values are available.
This is the currently code. Which only returns 1 row, instead of 20 rows:
public void CreateTaskListBAQView()
{
// Initialize the BAQDataView by giving it the BAQ name that will be used.
baqViewTaskList = new BAQDataView("MGATaskList-V2");
// This will add the BAQDataView to the form, so we can bind it to the grid. The DataView will be called "CustTrackershipment".
oTrans.Add("MGATaskList",baqViewTaskList);
string pubBinding = "Task.SalesRepCode"; // this is the actual table name from the Task view.
string pubBinding2 = "Task.DueDate"; // this is the actual table name from the Task view.
IPublisher pub = oTrans.GetPublisher(pubBinding); // if the publisher exist, then a publisher name will be returned.
IPublisher pub2 = oTrans.GetPublisher(pubBinding2);
// The following code is only needed if the filter field "Customer.CustID" have NOT been published. In this case I am using a standard column.
// Most likely the CustID is published. If this was an uncommon column like a UD field, I would need to check and publish the field. The code in
// place will check for this condition. The purpose of the publisher, is everytime the Customer.CustID is changed, the new value becomes available
// and the BAQ DataView is filtered accordingly. The BAQ DataView will have all the customers in it.
if(pub==null) // if no publisher
{
//MessageBox.Show("if not null".ToString());
oTrans.PublishColumnChange(pubBinding, "MyCustomPublish1"); // publish it
pub = oTrans.GetPublisher(pubBinding); // get a hold of that publisher
}
if (pub2==null)
{
//MessageBox.Show("if not null".ToString());
oTrans.PublishColumnChange(pubBinding2, "MyCustomPublish2"); // publish it
pub2 = oTrans.GetPublisher(pubBinding2); // get a hold of that publisher
}
// MessageBox.Show("before if pub != null".ToString());
if(pub !=null) // if we have that publisher available then we want to subscribe (filter) the BAQDataView to that publisher
// Filter on Task_SalesRepCode.
baqViewTaskList.SubscribeToPublisher(pub.PublishName, "Task_SalesRepCode"); // this is the actual column name from the BAQ
if (pub2 != null)
baqViewTaskList.SubscribeToPublisher(pub2.PublishName, "Task_DueDate"); // this is the actual column name from the BAQ
With as many questions as you’ve asked regarding code, I am surprised you still arent using:
```cs Your Code Here ```
Chris, I am sorry (really) but I am not sure what you mean. ````cs ?
Edit your response up top with code. Add the```cs
above the code
Add the other bit below the code -> ```
Thank you for reminding me.
I reverted to one subscription column the SalesRepCode because this returns all rows when the SalesRepCode is changed. However, when End/DueDate is changed the Task DV rows are decreased/increased but the BAQdv does not get updated with the decreased/increased rows. I even tried clearing the grid of the BAQdv before changing the DueDate.
I need to figure out the syntax for the <= DueDate published column? does anyone know how to do this?
Sounds like you need to look into filtering, not subscribe
I like your idea. I researched and found the following code example, which I have modified to my environment.
UltraGridBand band = this.myGridTaskList.DisplayLayout.Bands[2];
// Set AllowRowFiltering to true to allow the user to filter rows. This is not
// necessary for filtering rows through code.
band.Override.AllowRowFiltering = DefaultableBoolean.True;
// You can enable or disable row filtering on individual columns too.
// Column's setting have higher precedence for that column than the band's
// override settings.
band.Columns["Task_DueDate"].AllowRowFiltering = DefaultableBoolean.False;
// Set the RowFilterMode off the override to AllRowsInBand so that the
// ultragrid makes use of UltraGridBand.ColumnFilters.
band.Override.RowFilterMode = RowFilterMode.AllRowsInBand;
// Clear any previous filters on that column.
band.ColumnFilters["Task_DueDate"].FilterConditions.Clear( );
// Add one conditions one that requires value be greater than 5 and another
// that requires that the value be less than 10. Also we want to And these
// conditions because the value must satisfy both conditions. To do that
// set the LogicalOperator on the ColumnFilter of that column to And.
//band.ColumnFilters["Task_DueDate"].FilterConditions.Add( FilterComparisionOperator.GreaterThan, 5 );
band.ColumnFilters["Task_DueDate"].FilterConditions.Add( FilterComparisionOperator.LessThan, args.ProposedValue );
//band.ColumnFilters["Unit Price"].LogicalOperator = FilterLogicalOperator.And;
However, I get the following error message:
Application Error
Exception caught in: mscorlib
Error Detail
============
Message: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Program: CommonLanguageRuntimeLibrary
Method: get_Item
Client Stack Trace
==================
at System.Collections.ArrayList.get_Item(Int32 index)
at Infragistics.Win.UltraWinGrid.BandsCollection.get_Item(Int32 index)
at Script.EndDateTable_BeforeFieldChange(Object sender, DataColumnChangeEventArgs args)
at System.Data.DataTable.OnColumnChanging(DataColumnChangeEventArgs e)
at System.Data.DataRow.set_Item(DataColumn column, Object value)
at Erp.UI.App.TaskListEntry.Transaction.populateSearchEndDate()
at Erp.UI.App.TaskListEntry.TaskListForm.LoadFormPopulateCustID(LaunchFormOptions LaunchFormOpts)
at Erp.UI.App.TaskListEntry.TaskListForm.OnFormLoaded()
at Ice.Lib.Framework.EpiBaseForm.formLoaded()
Corrected the error with the following line change:
this.myGridTaskList.DisplayLayout.Bands[0];