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 :
Supply chain | Supply Chain Management, Commerce
Unanswered

Create new method rule validation on Commerce Parameter > Transaction Validation

(0) ShareShare
ReportReport
Posted on by

Dear All,

I have a requirement to create a new rule validation after we run P-001 job on D365FO. This rule is check Batch Id and Serial Id for sepecific Item. So how can I create new method on RetailTransactionValidationLine class and load it into the Rules Grids as image below. Please help me if you guys have any ideas or suggestion. Thanks a lots

Path:  Retail & Commerce > Head quarter setup > parameters > Commerce Parameters > Transaction Validation 

4747.2021_2D00_05_2D00_27_5F00_10_2D00_19_2D00_12.png

Phuoc Dinh

I have the same question (0)
  • Juliet Zhu Profile Picture
    Microsoft Employee on at

    Hello Phuoc Dinh,

    Thank you for using Microsoft Dynamics Communities.

    To create a custom validation rule, you need to:

    • Add new member to the RetailTransactionValidationType extensible enum
    • Create a class that extends RetailTransactionValidationBase
    • For header validations, you need to create a method that resembles the one below:

    [
    RetailTransactionValidation(RetailTransactionValidationRuleType::TransactionLevel, "@Retail:ConsistencyCheckerCustomerAccountDescription"),
    RetailTransactionValidationApplicableToAllTypes
    ]
    public boolean validateCustAccount() {}

    • For line validations, you need to create a method that resembles the one below:

    [
    RetailTransactionValidation(RetailTransactionValidationRuleType::LineLevel, "Validates if the serial number contains unprintable characters"),
    RetailTransactionValidationApplicableToAllTypes
    ]
    internal void validateSerialItemWithUnprintableChars(ItemInfo _itemInfo) {}


    Whenever you detect a problem, you should use either:

    • this.insertValidationErrorForTransaction(RetailTransactionValidationType::CUSTOM_ENUM, errorMessage)
    for header level failures.

    • this.insertValidationErrorForTransactionWithLineReference(RetailTransactionValidationType:: CUSTOM_ENUM, errorMessage, _itemInfo.LineNumber)
    for line level failures.


    By doing this, the validation failure will be caught by the framework and we will automatically mark the transaction as failed.

    You can use RetailTransactionValidationHeader & RetailTransactionValidationLine as examples.

    Note: once you do this, the new rule should automagically show up in Commerce Parameters > Transaction Validation.

    Hope it helps.

    Juliet Zhu

    If my information answers your question please click 'Yes' against "Did this answer your question?" to help other community members. 

  • Community Member Profile Picture
    on at

    Dear Juliet Zhu,

    Thank so much for your guidance very clealy. I tried to follow with all your steps but after try to build project and hole model also my new rule still not show up in Rules Grid. Please help me if you have any idea

    Best regards

    Phuoc Dinh

  • Juliet Zhu Profile Picture
    Microsoft Employee on at

    Hi Phuoc,

    Could you open a support ticket with Microsoft to get someone checking your environment directly?

    Thanks,

    Juliet

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 April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
André Arnaud de Calavon Profile Picture

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

#2
Laurens vd Tang Profile Picture

Laurens vd Tang 92 Super User 2026 Season 1

#3
Zain Mehmood Profile Picture

Zain Mehmood 89 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans