Moving UDF main screen empty when using linkbutton
Paul Witmond
Hi,We use standard code for moving an UDF to the main screen :
public void EquipmentFormLoad(FormLoad ev)
{
TextEdit udf_a = TextEdit.CreateNew("udf_a");
TextEdit ref_item = TextEdit.GetFromUID(ev.Form, "43");
udf_a.SetSizeAndPosition(Label.GetFromUID(ev.Form, "162").Left,ref_item.Top,ref_item.Width*3,ref_item.Height);
udf_a.DataBind = DataBind.CreateNew("UDF_Oms");
udf_a.DataBind.TableName = "OINS";
udf_a.DataBind.Alias = "U_Omschrijving";
udf_a.DataBind.DataBound = true;
ev.Form.AddItem(udf_a);
ev.Form.Update();
}
This is working fine when we open the screen manually and use the record select buttons.
But when we open the screen through a link button both fields are empty and the screen is in update mode
We open the customer equipment screen.
Please help
Thanks,
Paul
Paolo Manfrin
Hi Paul,we did introduce the event FormLoadedEvent.
The purpose of this event is exactly to avoid situations like the one above.
Unfortunately we discovered that SAP triggers the events on a different order when you open a form via the linked arrows instead of the main menu.
We then created this new event which takes care of those different orders and gets triggered at the end when the form is ready and displayed.
Hth
paolo
Paul Witmond
Hi Paul,
we did introduce the event FormLoadedEvent.
The purpose of this event is exactly to avoid situations like the one above.
Unfortunately we discovered that SAP triggers the events on a different order when you open a form via the linked arrows instead of the main menu.
We then created this new event which takes care of those different orders and gets triggered at the end when the form is ready and displayed.
Hth
paolo
Hi Paolo,
Can you show an example how I can do this using the framework ?
Tnx,
Paul
Lukas
Hi Paul,
You have to set the event type of your rule to "FormLoadCompleted" in the optimizer.
Anders Olsson
Hi Paul,
There is a global event in the framework, "FormLoadedEvent". This event will be raised in three different cases:
1. When a form is opened the normal way (from the menu or Form.Load())
2. When a form is opened from a LinkedButton (yellow arrow)
3. When browsing to a different record in a form
You will want to run your code in case 1 and 2 but not 3 (because then the form is already open).
In the startup of your add-on, attach a handler to the event:
SwissAddonFramework.Global.FormLoadedEvent += new Global.FormLoadedEventHandler(Global_FormLoadedEvent);
private void Global_FormLoadedEvent(string formUID, string formTypeEX, object pVal, ref bool bubbleEvent)
{
if (formTypeEX == "150") // Filter on relevant form type
{
if (pVal is SAPbouiCOM.ItemEventClass)
{
// Form was opened from the menu
SAPbouiCOM.ItemEventClass pVal1 = (SAPbouiCOM.ItemEventClass)pVal;
// Add the UDF here
}
}
bubbleEvent &= true;
}
If pVal is an instance of SAPBouiCOM.ItemEventClass, it means case 1 or 2 (above) have occured.
In case 3 (browsing), pVal will be an instance of SAPbouiCOM.BusinessObjectInfoClass.
HTH,
Anders
Please sign in to leave a comment.
Comments
0 comments