Ok the solution to this was to use the delegate method in the switch case (default case)
default:
EventHandlerResult result = new EventHandlerResult();
this.getBufferByDataSourceNameDelegate(_formDataSourceName, _itemId, _forUpdate, result);
if (!result.hasResult())
{
throw error(Error::wrongUseOfFunction(funcName()));
}
common = result.result();
We need to create a subscribed method
1- create a class
2- Add a subscribe method, that subscribes to getBufferByDataSourceNameDelegate delegate
[SubscribesTo(formStr(EcoResProductCreate), delegateStr(EcoResProductCreate, getBufferByDataSourceNameDelegate))]
public static void EcoResProductCreate_getBufferByDataSourceNameDelegate(str _formDataSourceName, ItemId _itemId, boolean _forUpdate, EventHandlerResult _result)
{
EcoResProduct ecoResProduct;
select RecId from ecoResProduct
where ecoResProduct.DisplayProductNumber == _itemId;
if(ecoResProduct)
{
EcoResProductTranslation ecoResProductTranslation = EcoResProductTranslation::findByProductLanguage(ecoResProduct.RecId,companyinfo::languageId(),_forUpdate);
_result.result(ecoResProductTranslation);
}
}