Skip to main content

Notifications

Announcements

No record found.

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 279
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?
  • Suggested answer
    Fubar Profile Picture
    Fubar 2,752 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.

  • Lucas H Profile Picture
    Lucas H 279 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
    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

  • Suggested answer
    Fubar Profile Picture
    Fubar 2,752 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
    Charles Abi Khirs Profile Picture
    Charles Abi Khirs 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

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

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,468 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans