Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Plugin to prevent customer can not check out more than 3 book at a time.

Posted on by 40

Dears,
i have a book entity with attributes (check out (Two Option) , Contact (Lookup) )
Would You Please Suggest The Logic To Create plugin To prevent the creation of book record if the associate contact had checked out 3 times in different records . 
Thanks

*This post is locked for comments

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: Plugin to prevent customer can not check out more than 3 book at a time.

    Register plugin on Create message of book entity. Use Preoperation

    Retrieve all book records that is associated with contact.

    If(Bookcount>2)

    {

    throw new invalidpluginexecutionexception("You are not allow to create contact as this contact already have three book records")

    }

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Plugin to prevent customer can not check out more than 3 book at a time.

    Create a plugin and register on the Pre-create of Book entity.

    In the plugin - Retrieve the contact and use queryexpression to retrieve its related book entity records. with check out field.

    then you accodingly check if record count is equal or greater then 3 and option checkout is Yes. Throw invalid plugin execution exception which will prevent the save.

    Hope this helps.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Plugin to prevent customer can not check out more than 3 book at a time.

    Hi,

    It looks straight forward.

    1) Create a plugin on book entity which triggers on create of book (Pre validation).

    2) Within the plugin, get the contact record.

    3) Using that contact entity, find the existing book records which has check out equals yes.

    4) If count is greater than 3 then throw invalida plugin execution exception with the message.

    Hope this helps.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans