Skip to Content
0

SAP B1 How to refresh the form with new data after update

Feb 16, 2017 at 12:34 PM

966

avatar image
Former Member

Hi Experts,

I have a requirements on project management window to do some calculations and change some form values (Planned cost and Actual cost) using DI API on Update event handler, the values are updated successfully on database but are not refreshed in the form until I press "Refresh button".on the toolbar.

How to make form refreshed with new values once updated. or is there an event - which I can handle in code - that happens after Update event completed?

if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD || pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_UPDATE)
{

//Code that will change planned and cost values

}

// if there is another event that happens after the update is completed, so I can activate the refresh in the toolbar

if (pVal.EventType == <Some event>)

{

Application.SBO_Application.ActivateMenuItem("1304");

}

I have been trying use oform.Update() & oForm.Refresh() and other workarounds with no luck

Thanks for your help.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
DIEGO LOTHER Feb 16, 2017 at 01:09 PM
0

Hi Shuqair,

You can use the item_pressed event on ItemEvent with beforeAction property equals false, but you need set some global variable that indicates that your update works correctly. Something like this:

        private bool _updated = false;


        private void Application_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)
        {
            BubbleEvent = true;
            if (BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_UPDATE
                && BusinessObjectInfo.ActionSuccess && !BusinessObjectInfo.BeforeAction)
            {
                //Do your update
                _updated = true;
            }
        }


        private void Application_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;
            if(!pVal.BeforeAction && pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && _updated
                && pVal.ItemUID.Equals("the id of your add/update button"))
            {
                Application.SBO_Application.ActivateMenuItem("1304");
                _updated = false;
            }
        }

Hope it helps.

Kind Regards,

Diego Lother

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks Lother,

This works fine but regarding using global variables, will it be a problem when multi users access the same addon concurrently?

Regards,

0

Hi Shuqair,

The global variable share your value on the scope of your application. But is not possible that the users use the same instance of one add-on concurrently. When an user log on SAP B1 and starts your add-on a new scope of the add-on will be created for this user, even this user log in a SAP B1 client in a server where there is a lot of other users logged.

Use global variables can be a problem in Web Applications, not in this situation.

Hope it clears.

Kind Regards,

Diego Lother

0
Gabriel Gonzalez Salazar Feb 16, 2017 at 01:03 PM
0

You tried doing it in the classic style:

if (pVal.EventType == <Some event>)
{ 
    Application.SBO_Application.ActivateMenuItem("1289"); //Previous data record
    Application.SBO_Application.ActivateMenuItem("1288"); //Following data record
}

Regards.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks Salazar,

Actually this will not work for sub-project management document since this is build in SAP as a tree, when you open the sub-project, all navigating arrow will be disabled.

Regards,

0