DocSF

DocSF

Did You Know?

Advanced visual search system powered by Ajax

Salesforce creazione dati per classe di test

Ecco un esempio di metodo per la creazione di dati in una classe di test

@TestSetup
    static void setup(){

        Date today = Date.today();
        Date tomorrow = today.addDays(1);

        // creare il Service Appointment
        ServiceAppointment serviceAppointment = new ServiceAppointment();
        serviceAppointment.EarliestStartTime = date.parse(String.valueOf(today.day() + '/' + today.month() + '/' + today.year()));
        serviceAppointment.DueDate = date.parse(String.valueOf(tomorrow.day() + '/' + tomorrow.month() + '/' + tomorrow.year()));
        serviceAppointment.ParentRecordId = workOrder.Id;
        serviceAppointment.Status = 'None';        
        serviceAppointment.SchedStartTime = date.parse(String.valueOf(today.day() + '/' + today.month() + '/' + today.year()));
        serviceAppointment.SchedEndTime = date.parse(String.valueOf(today.day() + '/' + today.month() + '/' + tomorrow.year()));
        //ServiceAppointment.ServiceTerritoryId,
        //ServiceAppointment.Status          
        insert serviceAppointment;
        
        // creare la service crew
        ServiceCrew serviceCrew = new ServiceCrew();
        serviceCrew.Name = 'Service Crew Test';
        serviceCrew.CrewSize = 20;
        insert serviceCrew;


        // creare l'assigned resource                
        AssignedResource assignedResource = new AssignedResource();
        assignedResource.ServiceAppointmentId = serviceAppointment.id;
        assignedResource.ServiceResourceId = serviceResource.id;
        assignedResource.EstimatedTravelTime = 11.00;
        assignedResource.ActualTravelTime = 12.00;
        assignedResource.ServiceCrewId = serviceCrew.id;
        insert assignedResource;

    }

Related Post

Salesforce lightning detect device

Per conoscere se siamo su mobile o desktop, tablet etc....

Salesforce Apex: Come arrotondare il prezzo (

Oggi ho avuto un problema con i decimali di un double d...

Come bonificare o aggiornare i campi di un og

Oggi ho avuto un problema con dei dati che ho bonificat...

Leave a Comment