• Sagar Hinsu 13
  • NEWBIE
  • 0 Points
  • Member since 2017
  • Software Developer

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
Hi All,
I have recently done the security scan of my application. 

I have one class where I am updating the fields. When scan report came it shows FLS update issues
 
global with sharing class CrmExternalDataSchechuleJob implements Schedulable{

    public Database.SaveResult sr {get; set;}
    global CrmExternalDataSchechuleJob() {
        
    }
    global CrmExternalDataSchechuleJob(Database.SaveResult saveResult) {
        this.sr = saveResult;
    }
    global void execute(SchedulableContext ctx) {
        
        Log__c Log = [SELECT id, Name,
                                             ActionType__c,
                                             Imported__c,
                                             LogType__c,
                                             Message__c,
                                             NumberOfRecords__c,
                                             SourceObject__c,
                                             CreatedDate
                                             FROM Log__c 
                                             WHERE id = :sr.getId() Limit 1];
        
        List<CrmPerformanceData__c> crmData = [SELECT id, Name,
                                                          Amount__c,
                                                          CrmCampaign__c,
                                                          CrmLeadSource__c,
                                                          CrmPerformanceDefinition__c,
                                                          Date__c,
                                                          Log__c,
                                                          Number__c
                                                          FROM CrmPerformanceData__c 
                                                          WHERE CreatedDate >= :Log.CreatedDate];
        
        if(crmData.size() > 0) {
            for(CrmPerformanceData__c crm : crmData) {
                crm.Log__c = Log.Id;
            }
            Log.Message__c = 'CRM Data Import Successful - Date ' + system.today().format() + ' Number of Records Imported - ' + crmData.size();
            
            update crmData;
        } else {
            Log.Message__c = 'CRM Data Import Successful - Date ' + system.today().format() + ' Number of Records Imported - 0';
        }
        Log.Imported__c = true;
        Log.NumberOfRecords__c = crmData.size();
        Log.SourceObject__c = 'External CRM';
        
        update Log;
        
    }
}

How do I check for the FLS Update for Log object at Line
Log.Imported__c = true;
Log.NumberOfRecords__c = crmData.size();
Log.SourceObject__c = 'External CRM';
update Log;​


Please ignore if any typing mistake or missing paranthesis.. 
Let me know if something is missing or Am I not clear in the question

I know there are so many question which answers this type of questions but my problem is little different. 
I have one object called CRMData__c in that I have Name, CRMDefinition__c(master-detail), Number__c, Date__c fields. 
So CRMData__c will have many records with Date, Number__C some number, and CRMDefinition id. 

I am showing some data example below for better understanding. 
User-added image

I got the record list in one variable List<sObject> result = "My result";
based on this result I want a JSON like below.

 

{
    "Test1": 12,
    "Test2": 11,
    "date": "2018-01-01"
  },
  {
    "Test1": 15,
    "Test2": 23,
    "date": "2018-01-02"
  },
  {
   "Test1": 20,
    "date": "2018-01-03"
  }

Means based on the date it should take the values of Test1 data and Test2 data.. 
I tried so many methods but it gives me the "APEX CPU Time Limit" error.
Because first I have to loop through the dates.
 
I have a scenario where I am scheduling a job throw apex class. 
Datetime sysTime = System.now().addMinutes(5);    
String SchTimer = '' + sysTime.second() + ' ' + sysTime.minute() + ' ' + sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + ' ? ' + sysTime.year();
system.schedule('scheduleDataJob_'+ SchTimer , SchTimer, new DataScheduleJob(sr));

I want to check whether this job is already scheduled or not? if it is not schedule then it should schedule and if it is scheduled then don't schedule it. 

I know there are so many question which answers this type of questions but my problem is little different. 
I have one object called CRMData__c in that I have Name, CRMDefinition__c(master-detail), Number__c, Date__c fields. 
So CRMData__c will have many records with Date, Number__C some number, and CRMDefinition id. 

I am showing some data example below for better understanding. 
User-added image

I got the record list in one variable List<sObject> result = "My result";
based on this result I want a JSON like below.

 

{
    "Test1": 12,
    "Test2": 11,
    "date": "2018-01-01"
  },
  {
    "Test1": 15,
    "Test2": 23,
    "date": "2018-01-02"
  },
  {
   "Test1": 20,
    "date": "2018-01-03"
  }

Means based on the date it should take the values of Test1 data and Test2 data.. 
I tried so many methods but it gives me the "APEX CPU Time Limit" error.
Because first I have to loop through the dates.
 
Hi guys.. I want to integrate facebook on salesforce.i want to know the process regarding this.
I want to fetch some data regaring the user..
pls tell me what things are required as i am using REST api.