Skip to main content

Notifications

Announcements

No record found.

Customer Service forum
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?

  • Suggested answer
    RudyZhang Profile Picture
    RudyZhang Microsoft Employee 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
  • Ibakordor Kharmih Profile Picture
    Ibakordor Kharmih 111 on at
    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 Microsoft Employee 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

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 284,876 Super User

#2
Ludwig Reinhard Profile Picture

Ludwig Reinhard Microsoft Employee

#3
Martin Dráb Profile Picture

Martin Dráb 225,425 Super User

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans