Skip to main content

Notifications

Announcements

No record found.

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

  • Juliet Zhu Profile Picture
    on at
    RE: Create new method rule validation on Commerce Parameter > Transaction Validation

    Hi Phuoc,

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

    Thanks,

    Juliet

  • Community Member Profile Picture
    on at
    RE: Create new method rule validation on Commerce Parameter > Transaction Validation

    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
    on at
    RE: Create new method rule validation on Commerce Parameter > Transaction Validation

    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. 

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 171 Super User 2025 Season 1

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 140 Super User 2025 Season 1

#3
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 127 Super User 2025 Season 1

Featured topics

Product updates

Dynamics 365 release plans