1

Let's say we have

//if(Schema.SObjectType.GroupMember.isCreateable()){
  if(GroupMember.sObjectType.getDescribe().isCreateable()) {
            insert usersToInsert;
        }  

commented line raises PMD issue during deploing and VS Code always warns about CRUD where can i read more about it?

3

Both have identical behavior, similar to how System.now() and DateTime.now() both return the current time in GMT. Both examples will return the current user's ability to create a GroupMember record. If, indeed, you're getting an error on the first example, file a bug with ApexPMD, as this is definitely a valid way to check CRUD permissions.

As a side note, the Schema isn't ordinarily required, making it an even shorter piece of code that I find more legible:

if(sObjectType.GroupMember.isCreateable()){

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.