0

We have a user that we have assigned a Permission Set to to allow them to delete Orders in Salesforce Lightning/CPQ. But when they click delete they get the following error:

D

We only want one user (outside the System Administrators) to be able to delete orders. So, the permission set we created was on the "Orders" Object giving the Read, Edit, Delete ability. And then assigned it to just that one user. They can see the delete button and click delete and when they confirm that they are ok with deleting they get the above error.

There is an existing Permission Set on the user called "Order Management" that provides Read and Edit ability of orders. We created a separate permission set for deleting the order because the Order Management permission set is assigned to several users and we only want one user to have the ability to delete orders.

Also, we do have the following Apex Trigger, which i believe is saying that if the order is "Linked to ERP" the order cannot be deleted:

trigger OrderTrigger on Order (before insert, after insert, before update, after update, before delete, after delete) {

if (Trigger.isBefore) {
    if (Trigger.isInsert) {
        // Code
    } 
    if (Trigger.isUpdate) {
        // Code
    }
    if (Trigger.isDelete) {

        for (Order eachOrder : trigger.old) {

            // check record eligibility for record deletion using isProtected method in DeleteProtection apex class
            boolean isProtected = DeleteProtection.isProtected(eachOrder);

            // if record is protected, throw error
            if (isProtected == true) {
                eachOrder.addError('This record cannot be deleted (Linked to ERP).');
            }
        }
    }
}

if (Trigger.IsAfter) {
    if (Trigger.isInsert) {
        // Code
    } 
    if (Trigger.isUpdate) {
        // Code
    }
    if (Trigger.isDelete) {
        // Code
    }
}

}

I am trying to determine what is causing this error.

Any suggestions, guidance or help would be great.

4
  • check also your Sharing Settings and OrgWideDefaults as CRUD access to Order is controlled by Parent (Account)
    – cropredy
    Nov 20, 2019 at 22:06
  • So, Parent (Account) is Private and Order s Public Read Only. Not sure if it matters, bBut the user I am trying to add the permission set to has access to all accounts, quotes, orders, etc. As she is in Sales Operations and supports all of Sales. Nov 21, 2019 at 16:10
  • There is a sharing rule that this user is in. Filter logic is Status equals Draft Nov 21, 2019 at 17:07
  • just having CRUD Delete permissions is insufficient - see SFDC Help
    – cropredy
    Nov 21, 2019 at 21:19

1 Answer 1

0

This was resolved using a permission set.

You must log in to answer this question.

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