Skip to main content
Became Hot Network Question
Added the debug logs
Source Link
salesforce Developer
  • 3.4k
  • 12
  • 57
  • 104

I have an apex method which basically checks if user has create access on Custom Object or not. Based on that it just returns true or false. If user has create permission in that case it's returning the true value but if I remove the create permission its not returning any value. In debug log I can see the Apex Method is called but noting in the lwc side.

As of now I'm calling my method on connectedCallback() where its working.

But I'm not able to understand why it's not returning any value when user doesn't have Object create permission.

Lwc.js

@wire(isObjectCreateable)
    isObjectCreate({ error, data }) {
        if (data) {
            this.isObjectCreatePermission = data;
            this.error = undefined;
            console.log(">>> isObjectCreatePermissionisProposalCreatePermission : " + this.isObjectCreatePermission );
            
        } else if (error) {
            this.error = error;
            this.isObjectCreatePermission = false;
            console.log(">>> isObjectCreatePermissionisProposalCreatePermission : " +error);
        }
    }

Apex:

@AuraEnabled(cacheable=true)
    public static Boolean isProposalCreateable(){
        SObjectType schemaType = Schema.getGlobalDescribe().get('Object__c');
        system.debug('>>> objectisProposal Createable '+schemaType.getDescribe().isCreateable());
        return schemaType.getDescribe().isCreateable();
    }

Debug Log:

  1. User Has Permission:

enter image description here a. apex:

b. Console log:

enter image description here

  1. User Does not have permission: a. apex: b. Nothing in console log enter image description here

I have an apex method which basically checks if user has create access on Custom Object or not. Based on that it just returns true or false. If user has create permission in that case it's returning the true value but if I remove the create permission its not returning any value. In debug log I can see the Apex Method is called but noting in the lwc side.

As of now I'm calling my method on connectedCallback() where its working.

But I'm not able to understand why it's not returning any value when user doesn't have Object create permission.

Lwc.js

@wire(isObjectCreateable)
    isObjectCreate({ error, data }) {
        if (data) {
            this.isObjectCreatePermission = data;
            this.error = undefined;
            console.log(">>> isObjectCreatePermission : " + this.isObjectCreatePermission );
            
        } else if (error) {
            this.error = error;
            this.isObjectCreatePermission = false;
            console.log(">>> isObjectCreatePermission : " +error);
        }
    }

Apex:

@AuraEnabled(cacheable=true)
    public static Boolean isProposalCreateable(){
        SObjectType schemaType = Schema.getGlobalDescribe().get('Object__c');
        system.debug('>>> object Createable '+schemaType.getDescribe().isCreateable());
        return schemaType.getDescribe().isCreateable();
    }

I have an apex method which basically checks if user has create access on Custom Object or not. Based on that it just returns true or false. If user has create permission in that case it's returning the true value but if I remove the create permission its not returning any value. In debug log I can see the Apex Method is called but noting in the lwc side.

As of now I'm calling my method on connectedCallback() where its working.

But I'm not able to understand why it's not returning any value when user doesn't have Object create permission.

Lwc.js

@wire(isObjectCreateable)
    isObjectCreate({ error, data }) {
        if (data) {
            this.isObjectCreatePermission = data;
            this.error = undefined;
            console.log(">>> isProposalCreatePermission : " + this.isObjectCreatePermission );
            
        } else if (error) {
            this.error = error;
            this.isObjectCreatePermission = false;
            console.log(">>> isProposalCreatePermission : " +error);
        }
    }

Apex:

@AuraEnabled(cacheable=true)
    public static Boolean isProposalCreateable(){
        SObjectType schemaType = Schema.getGlobalDescribe().get('Object__c');
        system.debug('>>> isProposal Createable '+schemaType.getDescribe().isCreateable());
        return schemaType.getDescribe().isCreateable();
    }

Debug Log:

  1. User Has Permission:

enter image description here a. apex:

b. Console log:

enter image description here

  1. User Does not have permission: a. apex: b. Nothing in console log enter image description here
edited tags
Link
Sebastian Kessel
  • 13.2k
  • 12
  • 38
  • 61
Source Link
salesforce Developer
  • 3.4k
  • 12
  • 57
  • 104

Wired Apex method is not getting called Particular Condition LWC

I have an apex method which basically checks if user has create access on Custom Object or not. Based on that it just returns true or false. If user has create permission in that case it's returning the true value but if I remove the create permission its not returning any value. In debug log I can see the Apex Method is called but noting in the lwc side.

As of now I'm calling my method on connectedCallback() where its working.

But I'm not able to understand why it's not returning any value when user doesn't have Object create permission.

Lwc.js

@wire(isObjectCreateable)
    isObjectCreate({ error, data }) {
        if (data) {
            this.isObjectCreatePermission = data;
            this.error = undefined;
            console.log(">>> isObjectCreatePermission : " + this.isObjectCreatePermission );
            
        } else if (error) {
            this.error = error;
            this.isObjectCreatePermission = false;
            console.log(">>> isObjectCreatePermission : " +error);
        }
    }

Apex:

@AuraEnabled(cacheable=true)
    public static Boolean isProposalCreateable(){
        SObjectType schemaType = Schema.getGlobalDescribe().get('Object__c');
        system.debug('>>> object Createable '+schemaType.getDescribe().isCreateable());
        return schemaType.getDescribe().isCreateable();
    }