function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gauri Kasat 8Gauri Kasat 8 

How to solve FLS Create Issues

Hello All,

I have run code scanner tool on my apex class and Visual force page. It give me FLS Create Issues.
I have solved these issues as per mention following URL

https://developer.salesforce.com/page/Testing_CRUD_and_FLS_Enforcement
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_perms_enforcing.htm

Again I have run code scanner tool on my apex class and Visual force page. It gives me again FLS Create Issue.
Let me know, if anything I miss

Following are the sample code:

  public PageReference startJourney(){
        if(test.isRunningTest()){
            valueLat = '18.51870548';
            valueLong = '73.93681982';
            existingAddresses = 'Amanora Town Centre, Amanora Town Centre, Amanora Park Town, Hadapsar, Pune, Maharashtra 411028, India';
        }
        Double lat = Double.valueOf(valueLat);
        System.debug('lat=>'+lat);
        Double lng = Double.valueOf(valueLong);
        System.debug('existingAddresses=>'+existingAddresses);
        System.debug('lng=>'+lng);
        // Create location record to store the Latitude,Longitude and Address
        journeys = [SELECT Id, Name, Journey_Start_Location__c, Date_Time__c, User__c,Address__c,IsActive__c, CreatedDate FROM Journey__c WHERE CreatedDate =TODAY AND IsActive__c=true AND User__c=: userInfo.getUserId()];
        
        System.debug('journeys=>'+journeys);
         Boolean isJourneyInsertable = Schema.sObjectType.Journey__c.fields.Date_Time__c.isCreateable() &&Schema.sObjectType.Journey__c.fields.Address__c.isCreateable() &&Schema.sObjectType.Journey__c.fields.User__c.isCreateable() &&Schema.sObjectType.Journey__c.fields.Journey_Start_Location__Latitude__s.isCreateable() &&Schema.sObjectType.Journey__c.fields.Journey_Start_Location__Longitude__s.isCreateable() &&Schema.sObjectType.Journey__c.fields.IsActive__c.isUpdateable();
         Boolean isLocationInsertable = Schema.sObjectType.Location__c.fields.Journey__c.isCreateable() &&Schema.sObjectType.Location__c.fields.Location_Name__Latitude__s.isCreateable() &&Schema.sObjectType.Location__c.fields.Location_Name__Longitude__s.isCreateable() &&Schema.sObjectType.Location__c.fields.Date_Time__c.isCreateable() &&Schema.sObjectType.Location__c.fields.Address__c.isCreateable() &&Schema.sObjectType.Location__c.fields.User__c.isCreateable() &&Schema.sObjectType.Location__c.fields.Location_Type__c.isCreateable();



        if(journeys.isEmpty()){
            jr  = new Journey__c(IsActive__c=true,Date_Time__c = System.now(),Address__c = existingAddresses, User__c=userInfo.getUserId(),Journey_Start_Location__Latitude__s =  lat, Journey_Start_Location__Longitude__s = lng);
            if(isJourneyInsertable){
                insert jr;
            }
            LatLong = new Location__c(Journey__c = jr.id,Location_Name__Latitude__s = lat,Location_Name__Longitude__s = lng,Date_Time__c = System.now(),Address__c = existingAddresses,User__c=userInfo.getUserId(),Location_Type__c='Start Location'); 
            if(isLocationInsertable){
                insert  LatLong;
            }
        }
        return null;
    }




Thanks in Advance
 
NagendraNagendra (Salesforce Developers) 
Hi Gauri,

Sorry for this issue you are facing.

May I suggest you please check with below link from the forums communty with a similar discussion which might help you further. Please let us know if this helps.

Thanks,
Nagendra
Gauri Kasat 8Gauri Kasat 8

Hey nagendra..

First of all, thankyou for replying..

As you can see i did the same thing but still i am facing this issue.

Please do reply if you have any other solution