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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

comment code in PurchTable method

(0) ShareShare
ReportReport
Posted on by 56

Hi Team,

I have debugged cod in PurchTable - setAddressFromInventSiteId()

In this method , I like to comment below code for testing purpose

if (!addressSet)
        {
            companyInfo = CompanyInfo::find();

            location = LogisticsLocationDefault::findSimpleDefault(companyInfo,role).RecId;
            if (location)
            {
                this.setLocation(location, companyInfo);
                addressSet = true;
            }
        }

        return addressSet;

How we can achieve this?

Pls give me more shed on this.

Thanks!

I have the same question (0)
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Comment it like you do in general if it is custom code. If standard you cannot comment. Then you can try doing a coc so that you have some value in addressset which skips the condition that helps your purpose of comment.

  • @rp@n Profile Picture
    56 on at

    Thanks Bharani,

    I like to return addressset to false. through CoC after next setAddressFromInventSiteId() what should i write?

    Pls give me more shed on this,

    thanks!

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    I don't know which method is this and what is there inside.

    Basic steps would be to check for this code and find that method and write a coc before next so that you should have some value assigned to this variable like hard-coded or something. So that if condition will be skipped.

  • @rp@n Profile Picture
    56 on at

    The method is SetAdddressfromInventSiteId from PurchTable already mentioned.

    The code which I mentioned only  like to skip from the method SetAddressfromInventSiteId through CoC that's it.

    Let t me know how will acheive this?

  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Please read my earlier comment again.

  • @rp@n Profile Picture
    56 on at

    I know, can you give me one example of sample code pls

  • @rp@n Profile Picture
    56 on at

    I like to declare flag = false;

    If (flag == false)

    {

       Like to skip the code above mentioned from the method setAddressFromInventSiteId() through CoC

    }

    Pls give me more shed on this

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    306,303 Super User 2026 Season 1 on at

    Hi Arpan,

    You can't skip coding in a CoC method. You can only add additional logic and influence a possible return value.

    If you need a temporary change for testing or debugging purposes only, you can relax the model to (temporary) allow overlayering, so you can out comment code as you need. See the next page on Microsoft Learn.

    Relax model restrictions to refactor overlayering into extensions - Finance & Operations | Dynamics 365 | Microsoft Learn

  • @rp@n Profile Picture
    56 on at

    Hi Andre, as per my requirement,  I have to skip those code . As you said, its wont possible then how can I make this possible?

    Kindly give me some solution pls

    Pls give me more shed on this

  • Suggested answer
    Mohit Rampal Profile Picture
    12,573 Moderator on at

    Hi, You can't change standard code but can manipulate (By pass) it. I tried to create the code snippet for you, please check and let me know if any issues. You need to be aware that if Microsoft updates code in standard setAddressFromInventSiteId method in future, you have to update it in your extended code as well. 

    [ExtensionOf(tableStr(PurchTable))]
    internal final class PurchTable_T_Extension
    {
        public boolean setAddressFromInventSiteId(InventSiteId _inventSiteId)
        {
            LogisticsLocationRecId      location;
            InventSite                  inventSite;
            boolean                     addressSet = false;
            CompanyInfo                 companyInfo;
            LogisticsLocationRole       role = LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Delivery);
           
            PurchaseType purchaseTypeLocal = this.PurchaseType;
    
            if (this.PurchaseType != PurchaseType::ReturnItem)
            {
                purchaseTypeLocal = this.PurchaseType;
                this.PurchaseType = PurchaseType::ReturnItem;
            }
    
            addressSet = next setAddressFromInventSiteId(_inventSiteId); 
    
            if (purchaseTypeLocal != PurchaseType::ReturnItem)
            {
                this.PurchaseType = purchaseTypeLocal;
    
                addressSet = this.isDropShipment();
    
                if (!addressSet && _inventSiteId && !this.InterCompanyDirectDelivery)
                {
                    inventSite = InventSite::find(_inventSiteId);
                    location   = LogisticsLocationDefault::findSimpleDefault(InventSite::find(_inventSiteId), role).RecId;
    
                    if (location)
                    {
                        this.setLocation(location, inventSite);
                        addressSet = true;
                    }
                }
    
                //if (!addressSet)
                //{
                //    companyInfo = CompanyInfo::find();
    
                //    location = LogisticsLocationDefault::findSimpleDefault(companyInfo,role).RecId;
                //    if (location)
                //    {
                //        this.setLocation(location, companyInfo);
                //        addressSet = true;
                //    }
                //}
    
            }
    
            return addressSet;
        }
    
    }

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Subra Profile Picture

Subra 396

#3
Martin Dráb Profile Picture

Martin Dráb 261 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans