• RahulForce
  • NEWBIE
  • 40 Points
  • Member since 2017
  • Salesforce Developer


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
Hi
I have problem in my project, because i have application components with a lot of components and i have to define some constance to use them across all components in application. What is the best approach for this? Currently I define a lot of attributes with default text value and I use them as constans but i think that isn't the best solution.
 
PMD extension in VS Code is reporting this issue:
Validate CRUD permission before SOQL/DML operation

I can handle this by using something of this sort:
if (Schema.sObjectType.Contact.fields.Email.isAccessible()) {
   Contact c = [SELECT Email FROM Contact WHERE Id= :Id];
}

However my codebase is huge and I cannot repeat this snippet everywhere. Also, the number of fields to be checked, similar to Email field, is large.

Hence, I want to write a generic utility method for this which will take as argumet the object name and a set of field names. 
public static Boolean hasFieldReadAccess(String objectName, Set<String> fields){
        Schema.SObjectType obj = Schema.getGlobalDescribe().get(objectName);
        for(String field: fields){
            Schema.SObjectField sObjectField = obj.getDescribe().fields.getMap().get(field);
            if(!sObjectField.getDescribe().isAccessible()){
                return false;
            }
        }
        return true;
    }
However, when I call this method at the lin where PMD reports issue, it does not show it as resolved. Even if I directly include the following line, the issue is not resolved:
if(Schema.getGlobalDescribe().get('Contact').getDescribe().fields.getMap().get('Email').getDescribe().isAccessible()){
 //SOQL here
}

Any idea what is going wrong here? Does PMD only recognize the first code snippet for resolving the issue?

 
What is the allowed syntax for v.attribute notation in controllers?

I found the same solution as @Jeff Hansen, but I'm curious about WHY. Why do we have to do
 
var a = component.get("v.item");
a.Packed__c = true;
component.set("v.item",a)

Instead of just doing
 
component.set("v.item.Packed__c",true)


to get the correct answer here?

I can't find documentation about this.

Thank you.

 

PS: is there a way to include code blocks in these questions and answers?

Hi
I have problem in my project, because i have application components with a lot of components and i have to define some constance to use them across all components in application. What is the best approach for this? Currently I define a lot of attributes with default text value and I use them as constans but i think that isn't the best solution.
 
Hi all,

Im currently facing an issue with the "e.force:createRecord" when trying to pre populate some fields from an object to another one. Im using the "defaultFieldValues" and almost every field is populated correctly (Lookup, text,etc) except Currency and Master-Detail.

For your understanding of the issue, when i query the data and show it on the console its shows completly fine ("234" currency field), but at the moment to pre populate it just dont, it keeps the field blank. Also ive tried to: ParseInt, Integer the value, and nothing.
Also, the fuctionallity on Classic mode it working fine, so its not a permision issue (Profile, FLS,etc).

Do you know why is this happenening? Happens to 2 different currency field and also to the master-detail (havent reasearch or even tried anything on this but if you can help also i will appreciate it).

Thanks!!