web
You’re offline. This is a read only version of the page.
close
Skip to main content
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 30

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
    RE: comment code in PurchTable method

    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
    30 on at
    RE: comment code in PurchTable method

    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
    RE: comment code in PurchTable method

    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
    30 on at
    RE: comment code in PurchTable method

    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
    RE: comment code in PurchTable method

    Please read my earlier comment again.

  • @rp@n Profile Picture
    30 on at
    RE: comment code in PurchTable method

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

  • @rp@n Profile Picture
    30 on at
    RE: comment code in PurchTable method

    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
    300,721 Super User 2025 Season 2 on at
    RE: comment code in PurchTable method

    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
    30 on at
    RE: comment code in PurchTable method

    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,565 Moderator on at
    RE: comment code in PurchTable method

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 683 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 563 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 398 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans