Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested answer

Prevent case creation

(0) ShareShare
ReportReport
Posted on by

Hi, I need to prevent a user from manual case creation for a certain type of account.
The condition is: If Account field equals Internal, pop an error message preventing user from creating the case.

Can you help share solution or the process on how can I do this?

  • Suggested answer
    RudyZhang Profile Picture
    RudyZhang on at
    Prevent case creation
    Hi,
     
    Here are some steps to use this sample code.
    1. Edit the application to find the form you need to change


    2. Click Add /On Save/ event to upload this function to /Web Resources/.


    3. Fill in the function to be called and check the box /pass execution context as first parameter/.
    4. Click /Save and Publish/ to publish the form and application.


     
     
     
     
     
     
    I hope my answer is helpful to you! If you have any other questions, please feel free to contact me.
     
    Best Regards,
    Rudy Zhang
  • Prevent case creation
    Thank you for the code, can you share where exactly do I upload the code. Is it on the button or form? Can you share the detailed steps from the start?
  • Suggested answer
    RudyZhang Profile Picture
    RudyZhang on at
    Prevent case creation
    Hi,
     
    We have analyzed your requirements, and we think that you can execute a custom JavaScript function on the /On Save/ event of the form that will popup if the value of a field in the form is a specific value and block the save.

    Here is some sample code.
     
    function testfunc(executionContext) {
        // get form context
        var formContext = executionContext.getFormContext(); 
        // replace 'title' with the logical name of your field
        var testfield = formContext.getAttribute("title"); 
    
        if (testfield != null) {
            var testFieldValue = testfield.getValue();
    
            if (testFieldValue == 'TTT') {
                executionContext.getEventArgs().preventDefault(); 
                // show error message
                alert('Error: Cannot create case for Internal account.'); 
            }
        }
    }
    


     
     
     
    I hope my answer is helpful to you! If you have any other questions, please feel free to contact me.
     
    Best Regards,
    Rudy Zhang

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal...

#2
Martin Dráb Profile Picture

Martin Dráb

#3
nmaenpaa Profile Picture

nmaenpaa

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans