web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

recreating button "add address" from standard form CustTable on the other standard form

(0) ShareShare
ReportReport
Posted on by 1,210

Hello guys,

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

4532.JPG

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

20178.JPG

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:

10245428.JPG

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?

I have the same question (0)
  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,095 on at

    Hi,

    Have you modified LogisticsLocationEntity::transactionPostalAddressFieldId to indicate which field from your table to use as address field?

  • dark_knight Profile Picture
    1,210 on at

    Thanks for the answer. I tried to put break point in this method from above and debugger doesn't go there. Seems like this method isn't involved in the logic. Anyway I tried to add the case for my table there and no result.

  • Sergei Minozhenko Profile Picture
    23,095 on at

    Hi Azat,

    Check also DirPartyPostalAddressFromHandler.main method, there is if statement for DirPartyPostalAddressFormHandler::isTransactionCommon and looks like you need to modify this method and probably DirPartyPostalAddressFormHandler::getTransactionEntity method too.

    If "isTransaction" variable is false for the class, "updateTransactionCaller" method on this class is not called.

  • dark_knight Profile Picture
    1,210 on at

    Hello Sergei,

    The thing is the method DirPartyPostalAddressFormHandler::isTransactionCommon also returns falls if you launch the logic from the original CustTable form. So seems like returning true isn't necessary for the logic to work correctly.

  • Sergei Minozhenko Profile Picture
    23,095 on at

    Hi Azat,

    I guess, i didn't understand you well with your requirement. Do you want to add ability to create and link addresses to service objects?

  • dark_knight Profile Picture
    1,210 on at

    Yes. You are right. What I did so far:

    1) I have created my own table SMAServiceObjectTableAddInfo_ICL and connected it to the standard table SMAServiceObjectTable via relation (pls see below). Also I have added a field ServiceObjectAddress to the table SMAServiceObjectTableAddInfo_ICL  which actually stores the address for the service object but in the form of the RECID of the LogisticsPostalAddress table(also via relation). Doing that I was able to add a reference group control to the form SMAServiceObjectTable. Also I have a field for the custAccount in my table SMAServiceObjectTableAddInfo_ICL which is also present on the form SMAServiceObjectTable. Using this custAccount field I was able to recreate a lookup for the control ServiceObjectAddress. Please see below screenshots:

    1588.JPG

    2) Here is the reference group control on the form SMAServiceObjectTable which was created automatically by the system when I drag and drop ServiceObjectAddress field from the table SMAServiceObjectTableAddInfo_ICL  to the form because it has relation to the LogisticsPostalAddress table using RecId field as you can see above:

    3288.JPG

    3) And finally I made a lookup for my ServiceObjectAddress control on the data source SMAServiceObjectTableAddInfo_ICL:

    public Common lookupReference(FormReferenceControl _formReferenceControl)
    {
    Common ret;
    CustTable custTable = CustTable::find(SMAServiceObjectTableAddInfo_ICL.CustAccountLoc);
    
    ret = LogisticsLocationSelectionLookup::lookupAddressForm(_formReferenceControl, custTable,
    [LogisticsLocationRoleType::Delivery], false);
    return ret;
    }

    Now I need to add ability to add new addresses to the field ServiceObjectAddress using add address button as it is on the standard custTable form

    I hope what I described shed some light on the case. Thank you and pls ask anything you need.

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,095 on at

    Hi Azat,

    Now I even more confused.

    If you want to create addresses in the same way as in Customer but for Service objects - you need to take a look at InventSite form and use LogisticsEntityPostalAddressFormHandler class.

    If you want to link an address from customer to service object and have the ability to add a new address from service object (but still link it to the customer) you need to look at SaleTable form and make changes as I mentioned in my previous comments.

  • dark_knight Profile Picture
    1,210 on at

    Hi Sergei,

    There is a form CustTable in the system. From there you can add address for the customer. They system somehow does it using  accountNum field I suppose. Is that correct?

  • Verified answer
    Sergei Minozhenko Profile Picture
    23,095 on at

    Hi Azat,

    Yes, it's using the customer record itself. If you want to create a customer address from another source, you need to modify isTransactionCommon and getTransactionEntity methods too. IsTransactionCommon will indicate that you will assign created address to your record (but you need to specify your field in LogisticsLocationEntity::transactionPostalAddressFieldId method). Method getTransactionEntity should return customer record related to your record (CustTable::find(SMAServiceObjectTableAddInfo_ICL.CustAccountLoc)).

  • dark_knight Profile Picture
    1,210 on at

    Thank you very much. I modified isTransactionCommon and getTransactionEntity methods. Also modified LogisticsLocationEntity::transactionPostalAddressFieldId method. And everything works like a charm. Million thanks))) you are a superstar) really!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 733

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 278 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans