DB Lookup - Difference between BPM and C# Screen Customization

Hi

Does the following type of call work in C# Screen Customization, or is this syntax used only for BPM? If it’s only BPM, what’s the simple equivalent in screen mod please?

Erp.Tables.Customer Customer;

//Get InActive flag from Erp.Customer, warn if inactive

Customer = (from Customer_Row in Db.Customer

        where Customer_Row.Company == callContextClient.CurrentCompany && Customer_Row.CustNum.ToString() == newBillToCustID

        select Customer_Row).FirstOrDefault();

if (Customer != null)

{

if( (bool)Customer["InActive_c"])

//throw new ApplicationException(“Warning - Customer is marked InActive.\n\nRequest that supply chain alter the InActive flag if required”);

this.PublishInfoMessage(“Warning - Customer is marked InActive.\n\nRequest that supply chain re-activate the customer if required”, Ice.Common.BusinessObjectMessageType.Error, Ice.Bpm.InfoMessageDisplayMode.Individual, “Customer”, “InActive”);

}

Many Thanks
Mark

That syntax is only used for BPM. If you are trying to perform the same logic in a screen customization, use the Customer adapter or depending on your form, it might already be a native data view.

1 Like

The easiest way to do this is to create a BAQ that pulls the data you want. Then add a parameter for Customer, set it as criteria for Customer against the BAQ. Then:

DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
dqa.BOConnect();
QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("YourBAQName");
qeds.ExecutionParameter.Clear();
qeds.ExecutionParameter.AddExecutionParameterRow("YourParamName",((Ice.Core.Session)oTrans.Session).CompanyID,"nvarchar",false,Guid.NewGuid(),"A");
dqa.ExecuteByID("YourBAQName",qeds);
//MessageBox.Show(dqa.QueryResults.Tables["Results"].Rows.Count.ToString());
if(dqa.QueryResults.Tables["Results"].Rows.Count > 0)
{
bool inActive = (bool)dqa.QueryResults.Tables["Results"].Rows[0]["Inactive_c"];
//dqa.DataSource = dqa.QueryResults;   // if you want to see data on a grid
}

Credit, where credit is due: @josecgomez Credit(c => c.IsDue == true)

4 Likes