web
You’re offline. This is a read only version of the page.
close
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 111

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?

I have the same question (0)
  • Suggested answer
    RudyZhang Profile Picture
    Microsoft Employee on at
    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
  • Ibakordor Kharmih Profile Picture
    111 on at
    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
    Microsoft Employee on at
    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 53 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 27 Most Valuable Professional

#3
Soundari Profile Picture

Soundari 15

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans