Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to limit adding to attachments to 5 for notes .

Posted on by 475

Hello,

While adding attachments to notes record how to limit attachments to 5 from front end?

What is the best way to restrict attachments??

  • Mayank Pujara Profile Picture
    Mayank Pujara 830 on at
    RE: How to limit adding to attachments to 5 for notes .

    as explained by other ppl earlier ..PreValidate plug in will make sense in this kind of scenario..

    check existing attachment list and if there are more then 5 then throw exception...

  • Suggested answer
    RE: How to limit adding to attachments to 5 for notes .

    Hello Partner,

    Hope this post finds you well.

    Unfortunately this configuration is not available in UI yet. In order to achieve it, you can register a plugin in pre create operation of annotation.

    In plugin logic, take the regarding object id and entity type and query the attachments for it. It will give you the collection, if it is greater than 5 then throw business process error that you cannot add more than 5 attachments.

    Make sure your plugin is register on synchronous mode.

    Thanks

    Hope this helps.

    Best regards,

    Ankit

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Verified answer
    meelamri Profile Picture
    meelamri 13,204 User Group Leader on at
    RE: How to limit adding to attachments to 5 for notes .

    Hello,

    unfortunately you can do it from front end only with an unsupported way and it's need big effort:

    First, you create new field (attachementsCounter) to count attachement regarding your record. Then a plugin wish will increment this field by 1 when an attachement is created.

    Well, after that you need a JavaScript function. It execute onChange of  the new field (attachementCounter). This function will hide the button (unsupported) you need to manupilate the DOM !!

    Personnally, i will handle this scenario only in the back-end. I will use the field attachementsCounter. If i reach the limit i will throw an exception...

    Mehdi,

    Please tick as verified if the answer is useful. 

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans