Preventing Users from Creating New Objects
Sometimes, business requirements dictate that a user should not be able to create a particular top-level object, such as an Opportunity. CRM Desktop cannot prevent users from attempting to create a top-level object using Microsoft Outlook's native features, such as the Ctrl-N shortcut or selecting File then New. However, CRM Desktop can ensure that the new form is read-only and prevent saving the form, thus preventing the creation of the new object.
In the example in this topic, the Opportunity form is configured to be read-only, preventing a user from creating a new object in the client. If you use this technique, then the user can still modify existing Opportunity.
To prevent a user from creating an object
Use a JavaScript editor to open the forms.js file.
For more information, see JavaScript Files in the Customization Package.
Locate thespecific type declaration functionthat is associated with the form you must modify.
For example, to make the Opportunity form read-only, locate the following function:
// OPPORTUNITY FORM SCRIPTS // function opportunity_form(ctx) { }
For more information, see Customizing Form Functions.
Add the following code:
{… if (!sb_helpers.check_first_sync(ctx)){…}: if (helpers.is_new_item(ctx.form.item)) { form_helpers.enable_form(ctx.form, false); … }
Save and then close the forms.js file
Republish the customization package.
For more information, see Republishing Customization Packages.