• Joshua Lim
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies
I am trying to automate code that will create a record of a custom object for a set of users. Querying the Cron Trigger shows that the job is being scheduled and is running according to schedule, but the records are not being created. Only when the job is run using Execute Anonymous does the logic actually take place. This is my first time working with the Schedulable interface, so any help would be much much appreicated!

The schedulable class is set up like this:
global class LM10_Scheduler implements Schedulable {
    
    global static void execute(SchedulableContext sc) {
        createResponses();
        scheduleJob();
    }

And here is the createResponses method:
public static void createResponses() {
        
        String fQ = getFiscalDates().fiscalQuarter;
        String fY = getFiscalDates().fiscalYear;
        Date deadline = getFiscalDates().deadline;

        List<User> users = filterUsers();

        //Insert an LM10 Response for all Users that are Active Employees and do not currently have an LM10 Response assigned to them
        if (!users.isEmpty()) {
            List<LM10_Response__c> responsesToInsert = new List<LM10_Response__c>();
            for (User user : users) {
                LM10_Response__c response = new LM10_Response__c(UserId__c = user.Id,     //assign the response to the appropriate user in the iteration
                                                                Status__c = 'To Be Completed',
                                                                Fiscal_Quarter__c = fQ,
                                                                Fiscal_Year__c = fY,
                                                                Deadline__c = deadline,
                                                                OwnerId = user.Id);	    //Set owner of the response to the user for whom the record is generated
                responsesToInsert.add(response);
            }
            try {
                insert responsesToInsert;
                System.debug('inserted new LM10 Responses');
            } catch (Exception e) {
                System.debug('insert failed');
                throw e;
            }
        }
    }

I can assume that scheduleJob() under the execute method is working, because a simple query into the CronTrigger shows accurate results. Let me know if you need more code, though I am thinking the rest of the class may be irrelevant to this question.
I am trying to automate code that will create a record of a custom object for a set of users. Querying the Cron Trigger shows that the job is being scheduled and is running according to schedule, but the records are not being created. Only when the job is run using Execute Anonymous does the logic actually take place. This is my first time working with the Schedulable interface, so any help would be much much appreicated!

The schedulable class is set up like this:
global class LM10_Scheduler implements Schedulable {
    
    global static void execute(SchedulableContext sc) {
        createResponses();
        scheduleJob();
    }

And here is the createResponses method:
public static void createResponses() {
        
        String fQ = getFiscalDates().fiscalQuarter;
        String fY = getFiscalDates().fiscalYear;
        Date deadline = getFiscalDates().deadline;

        List<User> users = filterUsers();

        //Insert an LM10 Response for all Users that are Active Employees and do not currently have an LM10 Response assigned to them
        if (!users.isEmpty()) {
            List<LM10_Response__c> responsesToInsert = new List<LM10_Response__c>();
            for (User user : users) {
                LM10_Response__c response = new LM10_Response__c(UserId__c = user.Id,     //assign the response to the appropriate user in the iteration
                                                                Status__c = 'To Be Completed',
                                                                Fiscal_Quarter__c = fQ,
                                                                Fiscal_Year__c = fY,
                                                                Deadline__c = deadline,
                                                                OwnerId = user.Id);	    //Set owner of the response to the user for whom the record is generated
                responsesToInsert.add(response);
            }
            try {
                insert responsesToInsert;
                System.debug('inserted new LM10 Responses');
            } catch (Exception e) {
                System.debug('insert failed');
                throw e;
            }
        }
    }

I can assume that scheduleJob() under the execute method is working, because a simple query into the CronTrigger shows accurate results. Let me know if you need more code, though I am thinking the rest of the class may be irrelevant to this question.
Hi Team,

trying to deisgn CSV uploder in lightning component and need to display in table after uploading CSV file and on click on save button need to save account reords in data base.
 
public class PMO_CsvUploaderController {
    public Blob csvFileBody{get;set;}
    public string csvAsString{get;set;}
    public String[] csvFileLines{get;set;}
    public List<Account> Acclist{get;set;}
    public PMO_CsvUploaderController(){
        csvFileLines = new String[]{};
            Acclist = New List<Account>(); 
    }
    
    public void importCSVFile(){
        try{
            csvAsString = csvFileBody.toString();
            csvFileLines = csvAsString.split('\n'); 
            
            for(Integer i=1;i<csvFileLines.size();i++){
                Account couObj = new Account();
                string[] csvRecordData = csvFileLines[i].split(',');            
                couObj.name = csvRecordData[1] ;        
                couObj.AccountNumber = csvRecordData[2];
                couObj.Phone = csvRecordData[3];
                couObj.Rating = csvRecordData[4];
                	/*
                    String temp_fees=csvRecordData[3];
                    couObj.Course_fees__c = Decimal.valueOf(temp_fees);
                    String temp_date=csvRecordData[4];
                    couObj.Course_Date__c = Date.parse(temp_date); 
                    */
                Acclist.add(couObj);   
            }
            insert Acclist;
        }
        catch (Exception e){
            System.debug(e.getCause());
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importing data. Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
        }  
    }
}

Using these contoroller to create account.. help me to design lightning component
I've tried this in two ways:
First:
component.set("v.columns",[
            {label:'', fieldName:'edit', type:'action', class: 'cols', cellAttributes: { iconName: { fieldName: 'utility:custom_apps' }}},
             ...
]);
Second:
<lightning:datatable data="{! v.data }"
		class="cols"
        columns="{! v.columns }"
        keyField="id"
		resizeColumnDisabled="true"
		hideCheckboxColumn="true"/>
	</lightning:card>

But neither of it works. Is it possible at all?
If needed, I here is my CSS as well
.THIS .cols {
    background-color: #16325c;
    color: white;
}