Skip to main content

1.Method does not exist or incorrect signature: void stripInaccessible(System.AccessType, Order) from the type System.Security

2.Method does not exist or incorrect signature: void stripInaccessible(System.AccessType, Account) from the type System.Security

  1. Method does not exist or incorrect signature: void stripInaccessible(System.AccessType, Order) from the type System.Security

  2. Method does not exist or incorrect signature: void stripInaccessible(System.AccessType, Account) from the type System.Security

1.Method does not exist or incorrect signature: void stripInaccessible(System.AccessType, Order) from the type System.Security

2.Method does not exist or incorrect signature: void stripInaccessible(System.AccessType, Account) from the type System.Security

  1. Method does not exist or incorrect signature: void stripInaccessible(System.AccessType, Order) from the type System.Security

  2. Method does not exist or incorrect signature: void stripInaccessible(System.AccessType, Account) from the type System.Security

Source Link
user3688231
  • 347
  • 1
  • 6
  • 19

After PMD Apex code change, getting alot of errors and can not deploy code

I recently had to modify my Apex class code because I ran a PMD Apex scan. After reading the SF docs, I made changes and the PMD Scan passed the code. However, when I started to deploy code, I am getting bunch of errors during deployed. Here is what I am getting:

1.Method does not exist or incorrect signature: void stripInaccessible(System.AccessType, Order) from the type System.Security

2.Method does not exist or incorrect signature: void stripInaccessible(System.AccessType, Account) from the type System.Security

I am really confused as to why I am getting this because I feel like I have followed the SF developer guide. Here is a sample of my apex class:

global with sharing class MyApexCtrl {
@AuraEnabled
    global static String createOrder(String firstName, String lastName, String title, String accId){
        
        if(firstName != '' && lastName != '' && title != ''){
            Product2 pr = getProductRecord();
            //Contact objCon = getContact(firstName, lastName, title, accId);
            //System.debug('To show contact :: '+objCon);
            
            String priceBookId = [SELECT Id, Name FROM Pricebook2 WHERE Name = 'Standard Price Book' Limit 1].Id;
            
            List<PricebookEntry> listPBEntry = [SELECT Id, Name, Pricebook2Id, Product2Id, UnitPrice, IsActive, UseStandardPrice 
                                                FROM PricebookEntry WHERE Pricebook2Id =: priceBookId AND Product2Id =: pr.Id 
                                                AND IsActive = True WITH SECURITY_ENFORCED];
            Order ord = new Order();
            ord.AccountId = accId;
            ord.EffectiveDate = Date.today();
            ord.Pricebook2Id = priceBookId;
            ord.Type = 'Regular';
            
            SObjectAccessDecision decision = Security.stripInaccessible(AccessType.CREATABLE, ord);
            insert decision.getRecords();

Account accUpd = new Account(Id = accId, Order_Confirmation__c = true);
            SObjectAccessDecision decisionAcc = Security.stripInaccessible(AccessType.UPDATABLE, accUpd);
            update decisionAcc.getRecords();
            
            return 'Order created successfully';
            
        }else {
            return 'Error';
        }
    }

Can someone please help me resolve this? Why is this code not deploying and why I am getting these errors during deploy? Thanks