Hello guys,
On the standard form CustTable a button for adding the new customer address can be found here:

and in the designer of CustTable form it can be found here:

MenuItem CustDirPartyPostalAddressNew launches the class DirPartyPostalAddressFormHandler which in turn launches the form called LogisticsPostalAddress for adding the new address. When I fill up the form LogisticsPostalAddress with the values of my new address and press OK it calls this piece of code from the main method of the class DirPartyPostalAddressFormHandler:
if (addressForm.closed() && !addressForm.closedCancel())
{
postalAddressForm.updateCallerPostalAddress(callerForm);
if(_args.caller() && _args.caller().name() == classStr(LogisticsLocationSelectionLookup))
{
_args.caller().close();
}
}
Here it calls the method updateCallerPostalAddress() from the same class - DirPartyPostalAddressFormHandler:
protected void updateCallerPostalAddress(FormRun _callerForm)
{
FormDataSource formDataSource;
Object callerObject;
//Refresh caller
formDataSource = _callerForm.dataSource(tableStr(DirPartyPostalAddressView));
if (formHasMethod(_callerForm, identifierStr(parmPostalAddressLocation)))
{
callerObject = _callerForm;
callerObject.parmPostalAddressLocation(this.parmLocation());
if (formDataSource)
{
formDataSource.research();
}
else if (formHasMethod(_callerForm, identifierStr(executePostalAddressQuery)))
{
callerObject.executePostalAddressQuery();
}
}
if(this.parmIsTransaction())
{
this.updateTransactionCaller(transaction);
if (tableHasMethod(transaction.dataSource() ,identifierStr(setDeliveryName)))
{
transaction.setDeliveryName();
formDataSourceRefresh(transaction);
}
}
}
Two string of code here seem interesting for me:
formDataSource = _callerForm.dataSource(tableStr(DirPartyPostalAddressView));
if (formHasMethod(_callerForm, identifierStr(parmPostalAddressLocation)))
I'm trying to add this button saving the same functionality for it but on the form SMAServiceObjectTable. I already has the field for the address in my custom datasource on this form. Also I have a custAccount field on my form so that when you choose the custAccount field for the address shows the first address for this custaccount and also lookup is working for all accessible addresses for this custAccount.
From these two string of code from above I see that it searches for the DirPartyPostalAddressView datasource so I added it to my form and have created a relation with the table which is datasource for my form:
1024
Then It also searches for the method parmPostalAddressLocation()on the form. So I have added the same method to the my from:
public LogisticsLocationRecId parmPostalAddressLocation(LogisticsLocationRecId _postalAddressLocation = dirPartyPostalAddressView.Location)
{
postalAddressLocation = _postalAddressLocation;
return postalAddressLocation;
}
But all this didn't help me. When I press the button it opens the form for adding address information but when I press OK it doesn't fill up my field with the new value and doesn't add the address. From the standard logic I don't understand where and what tables are updated with the newly entered data for the new address? I tried to put breakpoints to each method of the class DirPartyPostalAddressFormHandler but still don't get where the actual writing of values occurs. Can you please help me?