Today is small tip, Many times, we have to took decision based on the name of menu on which form is called. By getting menu name we can use same form for different purposes. We can write logic based on current form called from which menu item.
Following is the code snippet helps you to achieve this.
[FormEventHandler(formStr(LogisticsContactInfoGrid), FormEventType::Initialized)]
public static void LogisticsContactInfoGrid_OnInitialized(xFormRun sender, FormEventArgs e)
{
FormRun formRun = sender;
if (formRun.args().menuItemName() == "CustomerLogisticsContactInfoGrid")
{
FormDataSource LogisticsElectronicAddress_ds =formRun.dataSource("LogisticsElectronicAddress");
LogisticsElectronicAddress_ds.InsertIfEmpty(true);
LogisticsElectronicAddress_ds.object(fieldNum(LogisticsElectronicAddress, Locator)).mandatory(true);
}