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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

How to skip Standard validate method?

(0) ShareShare
ReportReport
Posted on by 25

Hi. everyone.

i have a some issue.

The validation logic of the standard table and class must be skipped. I would like to ask if this is technically possible.

I know how to set the Ret value to true with COC method.

However, what should I do if there is a "throw error" in the middle of the standard source code as shown below?

Even if i put "next" in front or behind, it will eventually fall into an error at that part.

i want to skip below code.

if (conFind(con, VendTable::find(purchReqLine.VendAccount).RecId) == 0)
{
throw error("@SYS300295");
}

PurchReqLineValidate (Class)

--------------------------

public boolean validateVendor()
{
ProcCategoryPolicyParameter procCategoryPolicyParameter;
List listVendors = new List(Types::Record);
boolean isCategoryAvailable = false;
boolean isValidItem = false;
boolean isVendorFound = false;
VendCategoryStatus vendCategoryStatus = -1;
boolean isApprovedOrStandard = false;
container con;

if (purchReqLine.isVendorBlocked())
{
return false;
}

// catalog Item
if ( purchReqLine.LineType == PurchReqLineType::Item )
{
isVendorFound = true;

if (this.validateInventItem())
{
if (purchReqLine.RequisitionStatus == PurchReqRequisitionStatus::Draft && purchReqLine.VendAccount)
{
con = PurchReqLine::findVendors(purchReqLine);

if (conFind(con, VendTable::find(purchReqLine.VendAccount).RecId) == 0)
{
throw error("@SYS300295");
}
}
}
else
{
throw error("@SYS306981");
}
}
else //Non-catalog item
{
isCategoryAvailable = this.checkCategoryAvailability();

if (!isCategoryAvailable)
{
return true;
}

// For approved purchase requisitions, it should be allowed to edit the vendor and the policy does not apply.
if (purchReqLine.RequisitionStatus == PurchReqRequisitionStatus::Approved)
{
return true;
}

procCategoryPolicyParameter = purchReqLine.procCategoryPolicyParameter();

if (procCategoryPolicyParameter.RecId != 0 )
{
// The reviewer selects the vendor during the review process if policy rule is 'Do not allow vendor selection in this category'.
if (purchReqLine.RequisitionStatus == PurchReqRequisitionStatus::InReview && procCategoryPolicyParameter.VendorSelection == ProcCategoryVendorSelection::SelectionNotAllowed)
{
return true;
}

isVendorFound = PurchReqVendorPolicyValidation::validateCategoryPolicyForVendor(procCategoryPolicyParameter.VendorSelection, purchReqLine.VendAccount, purchReqLine.ProcurementCategory,
purchReqLine.RequiredDate, purchReqLine.BuyingLegalEntity);
}
else
{
isVendorFound = true;
}

if (!isVendorFound)
{
return checkFailed("@SYS345136");
}
}

return isVendorFound;
}

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

    Even if you write COC also the standard checkfailed will execute. To suppress that what can be done is you need to give some default value before going into that condition.

    I mean something you can try like value>1; before the standard code in coc.

    So the debugger never enters to if condition.

  • js lee Profile Picture
    25 on at

    Hi. Bharani.

    Do you have an example source or link to refer to?

  • Verified answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    There is a nothing you can do. What Preka mean is; you can set values at the COC(before next) so control can skip at the code

    For Example lest focus a part of code

    if (this.validateInventItem())
    		{
    			if (purchReqLine.RequisitionStatus == PurchReqRequisitionStatus::Draft && purchReqLine.VendAccount)
    			{
    				con = PurchReqLine::findVendors(purchReqLine);
    
    				if (conFind(con, VendTable::find(purchReqLine.VendAccount).RecId) == 0)
    				{
    					throw error("@SYS300295");
    				}
    			}
    		}
    		else
    		{
    			throw error("@SYS306981");
    		}

    If you can set values so validateInventItem return true and "RequisitionStatus != PurchReqRequisitionStatus::Draft" code will skip throw lines.

    Or you can try catch error at COC 

    But from my experience don't messup this type code bucause someobody trying stoping the code and he has own resaon

  • js lee Profile Picture
    25 on at

    thank. i'm understand.

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 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans