• Prashanth Salimatt
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hi Everyone,
I am new to test class, i wrote a schedulde class in which i am accessing metadata and i am cloneing one task record into 3 diffrent records by change some details.
I wrote test class for that,but i am getting only 13% coverage.
Please some one can help to achive that to atleatst 80%.
below is my code for schedulde class.

public class TaskCreation implements Schedulable{
    public String taskType;
    public  void execute(SchedulableContext SC){
        List<Task_Setting__mdt> TaskSettings =  [SELECT Type__c, Id, Contact_Type__c, UserId__c FROM Task_Setting__mdt where Type__c = :this.taskType];
        Main_Task__mdt mtmd=[SELECT Id, Fetch_Value__c, Taak_Id__c FROM Main_Task__mdt where Fetch_Value__c=:this.taskType];
        Task taskrec = [SELECT Id, WhoId, WhatId, Subject, ActivityDate, Status, Priority, OwnerId, Description, AccountId, IsClosed, CallDurationInSeconds, ReminderDateTime, IsReminderSet, Task_Name__c, CompletedDateTime, TaskSubtype FROM Task where id=:mtmd.Taak_Id__c];
        List<Task> taskList=new List<Task>();
        for(Task_Setting__mdt tmdts:TaskSettings){
            Task newTask=taskrec.clone(false,false,false,false);
            newTask.OwnerId=tmdts.UserId__c;
            Datetime dt = DateTime.newInstance(Date.today(), Time.newInstance(0, 0, 0, 0));
            String dayOfWeek=dt.format('EEEE');
            System.debug('Day : ' + dayOfWeek);
            //newTask.Description = 'Task'+(System.now()).date().format();
            newTask.Day__c = (System.now()).date().format()  +  (System.now().Format('w'))  +  dayOfWeek;
            if(tmdts.Contact_Type__c=='Primary'){
                newTask.ActivityDate=system.today();
                newTask.ReminderDateTime=system.today();
            }
            else if(tmdts.Contact_Type__c=='Secondary'){
                newTask.ActivityDate=system.today()+1;
                newTask.ReminderDateTime=system.today()+1;
            }
            else if(tmdts.Contact_Type__c=='Manager'){
                newTask.ActivityDate=system.today()+2;
                newTask.ReminderDateTime=system.today()+2;
            }
            taskList.add(newTask);
        }
        insert taskList;
    }

Thanks in advance , your help would be appreciable.

Regards,
Prashanth.
Hi , 
Thank you in advance.
I want to add custom error message in community login page when deactivated user tried to login he should get "please check your mail "  instead "Your access is disabled. Contact your site administrator." this standard message


User-added image

Please anyone suggest the solution with code in ligntning

Regards,
pachi
Hi , 
Thank you in advance.
I want to add custom error message in community login page when deactivated user tried to login he should get "please check your mail "  instead "Your access is disabled. Contact your site administrator." this standard message


User-added image

Please anyone suggest the solution with code in ligntning

Regards,
pachi