web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Prevent a Main Form from being used to create a new contact

(0) ShareShare
ReportReport
Posted on by 283
I've got a separate app for a department that works with kids. This app has one form to view the kids info and another for parents info.
In this app ONLY kids records would be created, so I don't want a user to accidentally fill in the parents form.
Unfortunately, it seems like D365 defaults to your last used Main Form when you click the New button on the contact ribbon.
Is there any way to make one Main Form the default creation form? Or to not allow a contact to be created with a certain form?
I have the same question (0)
  • Suggested answer
    Charles Abi Khirs Profile Picture
    3,569 on at
    RE: Prevent a Main Form from being used to create a new contact

    Hello,

    You can force a specific entity form to be opened in javascript.

    Check the following link for more details: docs.microsoft.com/.../openform

  • Suggested answer
    Fubar Profile Picture
    2,761 on at
    RE: Prevent a Main Form from being used to create a new contact

    For the App, only include the specific form and not multiple forms.

    One possible way,  create a specific form for the App, in the onload add JavaScript to check the Form Type "formContext.ui.getFormType()" this will tell you if the form is in create, edit, readonly etc mode - codes are at the link following.  If 'create' put a Dialog (e.g. openConfirmDialog or openErrorDialog) up and on close of the dialog perform a  formContext.ui.close();

    docs.microsoft.com/.../getformtype

    You can also do things such as check the App being used

    docs.microsoft.com/.../getcurrentappname

    docs.microsoft.com/.../getcurrentappurl

  • Suggested answer
    Yoshika Suzuki Profile Picture
    on at
    RE: Prevent a Main Form from being used to create a new contact

    How about setting a security role on a form?

    https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/admin/assign-security-roles-form

  • Lucas H Profile Picture
    283 on at
    RE: Prevent a Main Form from being used to create a new contact

    LA

    Forgive my ignorance, but would this JS be put into a web resource for the Contact entity? Would it slow things down in other apps if it's always checking what app is being used and if it's in a create mode? 

    I've always been told that JS is a last resort. Is this a safe use of it or should this be avoided?

  • Suggested answer
    Fubar Profile Picture
    2,761 on at
    RE: Prevent a Main Form from being used to create a new contact

    There are things that you cannot do with business rules etc,

    Yes would be in a Web Resource that you added to the Form Properties (not embedded/inserted in the form), and then hooked up to the From on OnLoad to call your JS functon.

    Your talking about a few lines of JavaScript in the scheme of things (1,000's of lines already there from Microsoft) generally would not be noticeable to other users.

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 179 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 110

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 61 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans