cancel
Showing results for 
Search instead for 
Did you mean: 

How to automatically update a Grid when Data changes ( New Entries in or out )?

marour
Participant
0 Kudos

Hello Friends,

does anyone know how to do like a RunTime updae of a Grid when Data change?

If I have a Grid that shows me all Buisness Partners and a new BP has been added then the Grid should be updated without need to press an Update Button for example!

I am using SDK.

Any Idees? specific Events maybe? anything like that?

or I should add an Update Button and keep clicking it ?

Thanks in Advance

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert

Hi marour,

Few questions:

  1. How you are adding the Business Partners?
  2. How the grid data is being populated? Using SQL Query?
  3. Grid exists on a User Form or the System Form?

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi marour,

You can use the following sample code:

public void FormDataEvent (ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)
		{
			BubbleEvent = true;

			if (BusinessObjectInfo.BeforeAction == true && BusinessObjectInfo.Type == "2" && BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD)
			{
				MessageBox.Show("Data is not added yet. ActionSuccess is " + BusinessObjectInfo.ActionSuccess + "");
			}

			if (BusinessObjectInfo.BeforeAction == false && BusinessObjectInfo.Type == "2" && BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD)
			{
				string Key = BusinessObjectInfo.ObjectKey;
				SAPbobsCOM.BusinessPartners oBP = (SAPbobsCOM.BusinessPartners)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);
				oBP.Browser.GetByKeys(Key);
				var CardName = oBP.CardName;
				MessageBox.Show("Data is added successfully. ActionSuccess is " + BusinessObjectInfo.ActionSuccess + "");
			}
		}<br>

BusinessObjectInfo.Type=2 means that Business Partners are being added.

Variable Key will contain the primary key of the Business Object(BusinessPartners-CardCode) value.

Once the new Business Partner is added, you can open or get your User Form and Load the data again to the grid.

Hope it helps!

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

marour
Participant
0 Kudos

Very Interesting. And where should this Methode be implemented?

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi marour,

SBO_Application.FormDataEvent += new SAPbouiCOM._IApplicationEvents_FormDataEventEventHandler(ref FormDataEvent);

It should be implemented/used the same way, you use other events like Menu Events, Item Events etc. for System/User Forms.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

marour
Participant
0 Kudos

I understand this point very well but my problem is the i want to trigger an Event that is happening in a Systemform which i didnt implement in my SDK-Code at all because its already there with all functions.

so I want to use something that is happening outside of Code to do something on a Form that i created.

I still can not find how to connect them!

The FormDataEvent must be implementet in the Business Partner Form right? I mean to be able to trigger the Add-Action for example or i did miss something here?

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi marour,

In that case, I would suggest you to refer to few SDK Samples in the following location: C:\Program Files (x86)\SAP\SAP Business One SDK\Samples.

Those should give you the idea how to handle the events using SAP Business One SDK.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

marour
Participant

It worked at the end.. Thank you very much

Answers (4)

Answers (4)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi marour,

You can use the following sample code:

public void FormDataEvent (ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)
		{
			BubbleEvent = true;

			if (BusinessObjectInfo.BeforeAction == true && BusinessObjectInfo.Type == "2" && BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD)
			{
				MessageBox.Show("Data is not added yet. ActionSuccess is " + BusinessObjectInfo.ActionSuccess + "");
			}

			if (BusinessObjectInfo.BeforeAction == false && BusinessObjectInfo.Type == "2" && BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD)
			{
				string Key = BusinessObjectInfo.ObjectKey;
				SAPbobsCOM.BusinessPartners oBP = (SAPbobsCOM.BusinessPartners)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);
				oBP.Browser.GetByKeys(Key);
				var CardName = oBP.CardName;
				MessageBox.Show("Data is added successfully. ActionSuccess is " + BusinessObjectInfo.ActionSuccess + "");
			}
		}<br>

BusinessObjectInfo.Type=2 means that Business Partners are being added.

Variable Key will contain the primary key of the Business Object(BusinessPartners-CardCode) value.

Once the new Business Partner is added, you can open or get your User Form and Load the data again to the grid.

Hope it helps!

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi marour,

You can use the following sample code:

public void FormDataEvent (ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)
		{
			BubbleEvent = true;

			if (BusinessObjectInfo.BeforeAction == true && BusinessObjectInfo.Type == "2" && BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD)
			{
				MessageBox.Show("Data is not added yet. ActionSuccess is " + BusinessObjectInfo.ActionSuccess + "");
			}

			if (BusinessObjectInfo.BeforeAction == false && BusinessObjectInfo.Type == "2" && BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD)
			{
				string Key = BusinessObjectInfo.ObjectKey;
				SAPbobsCOM.BusinessPartners oBP = (SAPbobsCOM.BusinessPartners)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);
				oBP.Browser.GetByKeys(Key);
				var CardName = oBP.CardName;
				MessageBox.Show("Data is added successfully. ActionSuccess is " + BusinessObjectInfo.ActionSuccess + "");
			}
		}

BusinessObjectInfo.Type=2 means that Business Partners are being added.

Variable Key will contain the primary key of the Business Object(BusinessPartners-CardCode) value.

Once the new Business Partner is added, you can open or get your User Form and Load the data again to the grid.

Hope it helps!

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi marour,

You can use the following logic:

1. Use the FormDataEvent to capture the Add/Update of new/existing Business Partner. Refer to SDK Help file for FormDataEvent.

2. Clear the Grid Data and upload the data again using the same SQL Query.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

marour
Participant
0 Kudos

Hi and Thank you again,

I am still struggeling about how is it possible to trigger the FormDataEvent from a system Form and use it in a Form that i created using SDK.

I still do not know how to catch the event that is coming from the systemForm into my Form to give the clear and upload data orders to my Grid.

marour
Participant
0 Kudos

Hello ankit.chauhan1 ,

Thank you very much for your answer.

1- I create a new Business Partner normaly so i open a new BP Form.

2- Yes! I user SQL Query

3- Grid exists on a User Form created using SDK.