Loading data in Matrix
Jose Ribeiro
Hi
I am struggling to get a matrix to load data. I have tried using the SystemDatasource as well as Datatable. Any help will be appreciated!
Sample code:
Jose Ribeiro
Can anyone post a sample using a matrix to load data?? I am in need of urgent assistance...
I believe the problem is with the SystemDataSource.
If I debug and setup over after the frm.Load() the SystemDataSource has 310 fields, however the Size (Rows) is 1, however the OCRD table has 20 rows. I just cannot get the SystemDataSource to get the data.
Paolo Manfrin
Hi,
by experience we suggest always to use a Grid instead of a Matrix.
In case you would reconsider the Grid as an option for your project I suggest you to use the following code:
You can test it creating a new menu rule.
try
{
Form f = Form.CreateNewForm("WK_OPENQ", SwissAddonFramework.Utils.UniqueStringGenerator.Next());
f.Value = "Sales Quotation Selection";
f.Top = f.Height = 600;
Grid g = Grid.CreateNew("G1");
g.Top = 20;
g.Left = 5;
g.Width = 400;
g.Height = 400;
Button btn = Button.CreateNew("BTN1");
btn.Top = g.Top + g.Height + 10;
btn.Left = 5;
btn.Width = 100;
btn.Value = "Generate PDF";
f.AddItem(g);
f.AddItem(btn);
f.Load();
g.ExecuteQuery(@"SELECT 'N' AS [Generate PDF], DocEntry, DocNum, DocDate, CardCode, CardName, DocTotal, DocCur FROM OQUT WHERE DocStatus = 'O'
ORDER BY DocDate DESC");
g.Columns["Generate PDF"].Type = SwissAddonFramework.UI.Components.GridColumn.Types.CheckBox;
SwissAddonFramework.UI.EventHandling.ItemEvents.ItemPressedEventHandler buttonPressEvent = null;
buttonPressEvent = delegate(SwissAddonFramework.UI.EventHandling.ItemEvents.ItemPressed btnPress)
{
try
{
for (int rowIndex = 0; rowIndex < g.Rows.Count; rowIndex++)
{
string generatePDF = g.GetValue("Generate PDF", rowIndex);
/*
if (generatePDF == "Y")
{
string docNum = g.GetValue("DocNum", rowIndex);
StatusBar.WriteSucess("Generating PDF for Offer nr. " + docNum);
string pdfPath = ExtCode_GeneratePdf(docNum);
// generate an activity for the generated PDF
SAPbobsCOM.CompanyService oCmpSrv = SwissAddonFramework.B1Connector.GetB1Connector().Company.GetCompanyService();
SAPbobsCOM.ActivitiesService oActSrv = (SAPbobsCOM.ActivitiesService) oCmpSrv.GetBusinessService(SAPbobsCOM.ServiceTypes.ActivitiesService);
SAPbobsCOM.Activity oAct = (SAPbobsCOM.Activity) oActSrv.GetDataInterface(SAPbobsCOM.ActivitiesServiceDataInterfaces.asActivity);
//SAPbobsCOM.ActivityParams oParam = null;
oAct.CardCode = g.GetValue("CardCode", rowIndex);
oAct.ActivityDate = DateTime.Now;
oAct.Activity = SAPbobsCOM.BoActivities.cn_Other;
oAct.Notes = "Quotation ";// +pdfPath;
oAct.DocEntry = g.GetValue("DocEntry", rowIndex);
oAct.DocType = "23"; // 23 -> Sales Quotation
oActSrv.AddActivity(oAct);
//long actCode = oParam.ActivityCode;
}*/
}
}
catch (Exception innerException)
{
StatusBar.WriteError(innerException.Message);
}
};
btn.AddHandler_ItemPressed(SwissAddonFramework.UI.Components.ModeComponent.FormModes.ALL, null, buttonPressEvent);
g.Columns["DocEntry"].Editable = false;
g.Columns["DocNum"].Editable = false;
g.Columns["DocDate"].Editable = false;
g.Columns["CardCode"].Editable = false;
g.Columns["CardName"].Editable = false;
g.Columns["DocTotal"].Editable = false;
g.Columns["DocCur"].Editable = false;
((TextEditGridColumn) g.Columns["DocEntry"].SpecificGridColumn).LinkObjectType = "23";
}
catch (Exception ex)
{
StatusBar.WriteError(pVal.RuleInfo.RuleName + " : " + ex.Message);
}
************
hth
paolo
dhaval
Hi Paolo,
I was facing the same issue, as per suggestion, I have used grid instead of matrix, have load data from one table successfully,
Which are the way to save modifications done by user on the screen/grid to final database table?
Best Regards,
Dhaval
Anders Olsson
SAPbobsCOM.Company company = SwissAddonFramework.B1Connector.GetB1Connector().Company;
SAPbobsCOM.BusinessPartners bp = (SAPbobsCOM.BusinessPartners)company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);
bp.GetByKey("cardcode");
bp.UserFields.Fields.Item("U_UDF").Value = "test";
int err = bp.Update();
Please sign in to leave a comment.
Comments
0 comments