1

I have a requirement for a custom Object, when user with certain profile (For example Sales) will click on "New" BUTTON (mentioned below is the screenshot of the same) then it should display error that "you don't have access to create new record" whereas for other profiles it should work as normal.

Users of those profile (sales as mentioned above) would be able to create the record of that object through a button on Opportunity related list but not thru "NEW" button on the HOME page of the object ('NEW' button on List view of the object which we get thru TAB).

So what is the best way to complete this requirement, I would really appreciate any kind of suggestion or solution.

enter image description here

3
  • Are you trying to ensure that members of the Sales team always have a related Opportunity when they create a record of your custom object? Whereas members of other profiles do not need to have a parent Opportunity? It seems like a validation rule on the custom object that checks the user's profile and the value in the Opportunity lookup would suffice.
    – Mark Pond
    Jan 19, 2017 at 16:28
  • Thanks Mark for the response but my problem is not yet solved. My requirement is users of certain profile shouldn't be able to create record thru 'New' button on List view which we can see when we click on the object on TAB Bar, but they should be able to create the record thru this "Submit to Credit" custom button (coded in JavaScript) on related list of Opportunity.
    – Sandip
    Jan 20, 2017 at 16:26
  • (1) Remove Create permission from Sales profile and (2) Change your custom button to invoke a VF page/controller that does the insert. Apex runs in system context and can create SObjects profile doesn't have access to - if that is your business use case
    – cropredy
    Jan 21, 2017 at 3:05

1 Answer 1

0

Three Steps:-

  1. Remove create permission from all those profiles for that Object

  2. Create new Permission Set and on that PermissionSet give permission to create record on that object.

  3. Assign the permission set to only those user who should be able to create record. Leave those who shouldn't. They even won't see "new" button.

7
  • Thanks Ashwani for your suggestion but it is not working as it is not allowing the user of that Profile to create the record of that custom thru related list (Opportunity) once the "Create" permission is removed from their profile. In the related list of Opportunity, we have a button "Submit to Credit", which
    – Sandip
    Jan 20, 2017 at 16:10
  • You will also need to assign that permission set to those users who you want to let them create records. @SandipSFDC
    – Ashwani
    Jan 20, 2017 at 16:11
  • Thanks Ashwani for your suggestion but it is not working. It isn't allowing the users of that Profile to create record of that custom object thru Opportunity related list once the "Create" permission" is removed. In Opportunity the related list, we have button "Submit to Credit" with JavaScritp coding which creates record of this custom object once it is clicked, so the requirement is users of certain profile shouldn't be able to create record thru 'New' button on List view but they should be able to create the record thru this "Submit to Credit" button on related list.
    – Sandip
    Jan 20, 2017 at 16:21
  • Assigning permission set will enable the users to create record thru 'NEW' button on List view.
    – Sandip
    Jan 20, 2017 at 16:23
  • 1
    That can't be controlled by profile. You will have to override the new button with visualforce page. That page will check if the user is eligible to create. Then redirect to create page otherwise show error or nothing. @SandipSFDC
    – Ashwani
    Jan 20, 2017 at 16:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .