Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

How to prevent the Save Functionality after clicking on Save button using Plugin and create a New record with the Updated Deatils

Posted on by 340

Hi Team,

I have a requirement which i need to be done by Plugin.

There have a Account Record and when i open that Account Record and modify some of the fields and click on Save then the Record should not gets Saved.

Instead it shows Some Custom Message that " New record gets Created" and create a New Record with that updated details.

I need to do this using Plugin. Can anybody give me any solution that how should i proceed and achieve the same.

Thanks in Advanced.

  • Suggested answer
    Saad Kabarousse Profile Picture
    Saad Kabarousse 732 on at
    RE: How to prevent the Save Functionality after clicking on Save button using Plugin and create a New record with the Updated Deatils

    Hello,

    you can use this :

    1- Create a javascript funtion

    2- pass to it the execution context as shown below

    pastedimage1571409764139v1.png

    3- Associate your function to Onsave event

    4- execContext.getEventArgs().preventDefault(); // To Prevent the Form Save

    Hope this helps

  • Suggested answer
    DynamicsAlex Profile Picture
    DynamicsAlex 25 on at
    RE: How to prevent the Save Functionality after clicking on Save button using Plugin and create a New record with the Updated Deatils

    You can achieve this by blocking the save (onSave javascript handler) and invoking a custom Action with a plugin attached to create the record, passing all the account fields to the Action. After the action completes and you are back in your JS you can display the alert and/or navigate to the new record.

    On a side note, this sounds like an excellent way of filling up the accounts with a boatload of duplicates, each differing by only a typo and devoid of any value. If I were you I'd prepare to delete and rework the whole thing in a matter of weeks.

  • Suggested answer
    Kipetcoff Profile Picture
    Kipetcoff 1,002 on at
    RE: How to prevent the Save Functionality after clicking on Save button using Plugin and create a New record with the Updated Deatils

    Hi,

    As I know you can just throw exception in Update or Create event.

      throw new InvalidPluginExecutionException("The record can't be saved")

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to prevent the Save Functionality after clicking on Save button using Plugin and create a New record with the Updated Deatils

    Hi,

    Do you really need to do this by plugin? I know that with javascript this is achievable, by plugin I don't think so.... Unless you throw an exception on plugin, on pre update event (but this is not a very "pretty" solution, neither throwing an exception).

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans