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!
The code is different from what I have provided. Please create an extension class and paste as it is.
Hi Mohit,
public boolean setAddressFromInventSiteId(InventSiteId _inventSiteId) { next setAddressFromInventSiteId(_inventSiteId); LogisticsLocationRecId location; InventSite inventSite; boolean addressSet = false; CompanyInfo companyInfo; LogisticsLocationRole role = LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Delivery); if (this.PurchaseType == PurchaseType::ReturnItem) { //Never set the address from the site if the purchase order is of type return order. return false; } 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;
This code is NOT returning any error.
Pls give me more shed on this.
thanks!
Hi Mohit,
I tried the code and got below issue
Pls give me more shed on this.
thanks!
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; } }
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
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.
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
I know, can you give me one example of sample code pls
Please read my earlier comment again.
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?
André Arnaud de Cal...
292,162
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156