Change of question. How to override correctly modified field in purchcreateorder? Right now it compiles but still the values didnt show in my form.
[ExtensionOf(formdatasourcestr(PurchCreateOrder, PurchTable))]
final class PurchCreateOrderGetDefAdress_Extension
{
[DataField]
class OrderAccount
{
void modified()
{
element.orderAccountModified();
InventLocation inventlocation;
UserInfoSz usrsz;
PurchTable purchtable;
FormDataSource ds;
FormDataObject df =any2Object(this) as FormDataObject;
next Modified();
ds = df.datasource();
PurchTable = Ds.cursor();
select InventLocation where InventLocation.inventsiteid == usrsz.InventSiteId && inventlocation.DefaultShipMaintenanceLoc == 'out';
purchtabke.orderaccount = '11111111111111111111';
purchtable.inventsiteid = 'ILA-LOG-01';// InventLocation.inventsiteid;
purchtable.inventlocationid = InventLocation.InventLocationId;
purchtable.DeliveryName = 'sasasasa';
//purchTable_ds.refresh();
}
}
To avoid code duplication in your case, create a static method in your event handler class and put your code there
public static void initLogisticsPostalAddress(...parameters...)
{
put your logic here
}
then call this method in both events:
[FormDataSourceEventHandler(formDataSourceStr(PurchCreateOrder, PurchTable), FormDataSourceEventType::initvalue)]
public static void PurchTable_Oninitvalue(FormDataSource sender, FormDataSourceEventArgs e)
{
PurchCreateOrderEH::initLogisticsPostalAddress(...parameters...);
}
Great. One more question. Since I try to init values I want to keep them even after I change PurchTable_orderaccount in PurchCreateOrder. Right now when I select a order account my init values are replaced. How can I prevent it ?
Why don't you put your init logic in a
modified
method ofOrderAccount
datasource field instead ofOninitvalue
events?Tried it now but my values didnt show up. Edited code in my post
Okay I got it. Forgot I can use events on fields. So I created a onmodified eventhandler any my values are updating right. Last but stil. Could you say me how can I select deliveryname, inventsiteid and inventlocationid from purchtable ? Every time I try I get nothing. while select firstonly InventSiteId, InventLocationId, DeliveryPostalAddress, DeliveryName from purch group by purch.DeliveryPostalAddress, purch.deliveryname where purch.InventSiteId == usrsz.InventSiteId && purch.InventLocationId != null && purch.InventSiteId != null