cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Business One 2007 A - How to refresh the data on a system form?

Former Member
0 Kudos

I am adding item lines in the sales quote system form, using part data from an external source after the user clicks a button (a new panel I added) using the Lines class in SAPbobsCOM.Documents. It's working, but the items don't show in the matrix (ie grid) until you close and re-open the form or navigate to another record and back. I tried calling the update() & refresh) on the form as the SDK says, but it's not working. I found the Refreash is depricated and Update just repaints the form. How do I refresh the data the sales quote matrix? (This a matrix already on the system form not one I added, so I cannot call LoadFromDataSource, etc on the matrix). Also, since the user needs to fill in the customer (and document date gets filled in automaticly) filled in the form to fille in the CardCode and DocDueDate on the SAPbobsCOM.Documents obect, when I tried using the naigate to another record and back workaround I found here (ActivateMenuItem("1289") , etc) I get a prompt that data will be deleted (of course since the user needs to fill in the customer). Can I suppress or get rid of this prompt? Is there a way to reload the data in system form like the refresh used to do? Do a need to move this code to my own form and just load the sales quote form when I'm done 'cause there's no way to refeash the item matrix on the sales quote form? Help!

Accepted Solutions (0)

Answers (9)

Answers (9)

Former Member
0 Kudos

Basically, refreshing a system form direcly and w/o promts can't be done.

Edited by: Robert Lempke on Sep 22, 2008 9:26 PM

former_member191896
Active Participant
0 Kudos

Hi Rob,

Since you are using a combination of DI API and System Form (UI API) to accomplish the task of adding a Sales Quotation, the refresh on system form becomes tricky.

When a document is added via DI API, it is reflected in database only and not in the Form/UI. There is no method available to do a data refresh on the system matrix/form.

You can try simulating a Find click and then query for the Doc number just added (if this fits your scenario).

Other alternative is to create a user form which would allow the user to fill all necessary information; then create a Sales Quotation using DI API;

Now you can load the data for the Sales Quotation in the system form (if needed).

Regards

Aravind

Former Member
0 Kudos

I tried the above, I got an error message ...

"Data Source - is not a user-defined object [66000-17]. Form Unique Id: 'F_57', Table Unique Id : 'QUT1'"

Former Member
0 Kudos

When I try to set editable to true :

oItemMatrix.Columns.Item("1").Editable = True

"Item - The item is not a user-defined item [66000-8]"

like I said this is a system form and a system matrix, so access to the matrix is restricted. It also means I can't use LoadFromDataSource either. That's why I'm using the documents object to insert the sales quote into the database - and it's working, but you have to reopen/navigate to see the lines in the matrix. I want to be able to show the lines w/o forcing tyhe system form to close/reopen/navigate, since the form always prompts "Changes will cause data to be deleted, Continue?" ... [sigh].

Eneveux
Product and Topic Expert
Product and Topic Expert
0 Kudos

Robert,

Basically here are some thing to review as an example ...

Dim oDBDataSource As SAPbouiCOM.DBDataSource

Dim oMatrix As SAPbouiCOM.Matrix

' getting the data sources bound to the form

oDBDataSource = Form.DataSources.DBDataSources.Item("OUSR")

' getting the matrix on the form

oMatrix = Form.Items.Item("Matrix1").Specific

oMatrix.Clear

' Querying the DB Data source

oDBDataSource.Query

' Adding the data to the matrix

oMatrix.LoadFromDataSource

Here you see the steps you must perform to read data from a database table (here OUSR) and display them in a corresponding row of a matrix.

If you pack this coding in a function where you can pass the handle of the form, you can also reuse this lines.

First of all, you get a handle to the Database data source and a handle to the matrix object on the form.

Using the Query method, you can retrieve data from the corresponding database table. You can specify the where clause for the resulting select statement by using the Conditions collection.

After having queried the data, you display the data on the matrix by calling the AddRow method.

The same procedure holds for user data sources:

You can get a handle to the user data source object with the following statement: oUserDataSource = Form.DataSources.UserDataSources.Item("Remarks")

Before adding the data to a row of the matrix on the form, you must set the value property of the user data source object with the following statement: oUserDataSource.Value = "my user data

HTH,

Eddy

Eneveux
Product and Topic Expert
Product and Topic Expert
0 Kudos

Robert,

With respect to your question ... please see the SAP Business One SDK samples for ...

... \Program Files\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\06.MatrixAndDataSources ...

... as this may help you.

Also see the SAP Business One SDK Help documentation on the Matrix Object and specifically the LoadFromDataSource method.

With respect to existing rows in the matrix and trying to change the ItemCode in the Documents_Lines object ... you are correct that this property is read only.

Eddy

Former Member
0 Kudos

"Public member 'Editable' on type 'ICell' not found."

Former Member
0 Kudos

Robert,

My bad...


oForm.Items.Item("MATRIX").Specific.Columns.Item("U_COLUMN").Editable = True
oForm.Items.Item("MATRIX").Specific.Columns.Item("U_COLUMN").Cells.Item("ROW").Specific.Value
oForm.Items.Item("MATRIX").Specific.Columns.Item("U_COLUMN").Editable = False

It's a member of Column

Regards,

Vítor Vieira

Former Member
0 Kudos

Huh?

Editable is not a member of a Cell object, the only members are Specific and click. (Nor is it a member of Iedittext).

Former Member
0 Kudos

Robert,

Have you tried it?! Do it and you'll see...

Regards,

Vítor Vieira

Former Member
0 Kudos

I treid loading the items directly into the matrix, using the that method, but the itemCode and quantity cells are readonly - I get a item is not editable error message.

Former Member
0 Kudos

Robert,

That's not a problem:


oForm.Items.Item("MATRIX").Specific.Columns.Item("U_COLUMN").Cells.Item("ROW").Editable = True
oForm.Items.Item("MATRIX").Specific.Columns.Item("U_COLUMN").Cells.Item("ROW").Specific.Value
oForm.Items.Item("MATRIX").Specific.Columns.Item("U_COLUMN").Cells.Item("ROW").Editable = False

Regards,

Vítor Vieira

Former Member
0 Kudos

Robert,

When working with system matrix's, you must set the value in the cell


oForm.Items.Item("MATRIX").Specific.Columns.Item("U_COLUMN").Cells.Item("ROW").Specific.Value

and not in the DataSource. The reason: like you said, you cannot use LoadFromDataSource in a system matrix.

Regards,

Vítor Vieira