• Sushil Dholani
  • 0 Points
  • Member since 2018

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
  • 0

Hello Salesforce Ohana,
Opportunity is connected with Custom Object A and Custom B.
Custom Object A and Custom Object B are only related by Opportunity (Lookup).

There is one more Custom object C.
Custom Object C is only connected to Custom object B not directly connected with Opportunity or Custom object A.

What I am trying to achieve to is When Custom Object c records are created then one of its fields I need to pass to Custom object A record.

Suppose 3 Custom object C records created so there will be already Custom object A 3 records available where I need to pass value from Custom object C.

It doesn't matter Custom Object C 1st number record data gets attached to Custom object A 3rd number but opportunity needs to be the same as values are unique.


Any suggestions or guidance will be helpful.

Thanks in advance
User-added image

Hello Salesforce Ohana,
I have created two custom Objects.
Job Post
Job Applicants - Junction Object ( Two Lookups contact and Job Post )

I want to first show List of contacts with the option to select them which can be possible by Datatable with Selectable rows

after that when I click on Next I want to show a list of Job posts and I want to assign selected contacts to selected jobs and create new records of Job Applicants.

Looking for some guidance/steps as I am new to lightning and recently started creating components

trigger MaintenanceRequest on Case ( after update) {
    // ToDo: Call MaintenanceRequestHelper.updateWorkOrders
	    for(Case c : Trigger.new){
        	if(Trigger.isAfter && Trigger.isUpdate){
public with sharing class MaintenanceRequestHelper {
    public static void updateWorkOrders() {
         list<case> insertCaseList = new list<case>();
        List<Case> ClosedCaseList =  [select id,Vehicle__r.Id,Equipment__r.Id,Equipment__r.Maintenance_Cycle__c,(select id from Work_Parts__r) from case where status = 'Closed' and Id IN :Trigger.new and Type in('Repair','Routine Maintenance') LIMIT 200];
        // TODO: Complete the method to update workorders
        for(Case c:ClosedCaseList){
        Case maintenanceRequest             = new Case();
        maintenanceRequest.Type             = 'Routine Maintenance';
        maintenanceRequest.Vehicle__c       = c.Vehicle__c;
        maintenanceRequest.Subject          = 'Routine Checkup';
        maintenanceRequest.Date_Reported__c = System.today();
        maintenanceRequest.Equipment__c     = c.Equipment__c;
        system.debug('NewCasesList: '+ insertCaseList);
        system.debug('CaseList: '+ ClosedCaseList);
        Integer i=0;
        List<Aggregateresult> agrResult = [SELECT MIN(equipment__r.Maintenance_Cycle__c)MinimumValue FROM WORK_PART__c where Maintenance_Request__c=:ClosedCaseList];
        for(Aggregateresult r: agrResult){
            system.debug('Agg result: '+r);
        		insert insertCaseList;
public class MaintenanceRequestTest {
    static void testMaintenanceRequest(){
        Date d = System.Today();
        List<Case> maintenanceList = new List<Case>();
        List<Case> maintenanceListClosed = new List<Case>();
        Vehicle__c vehicle = new Vehicle__c(Name='tata sumo',Air_Conditioner__c=true,Model__c='23Test');
        insert vehicle;
        Product2 equipment = new Product2(Name='tire',Cost__c=100,Current_Inventory__c=10,Replacement_Part__c=true,Warehouse_SKU__c='test',Lifespan_Months__c=10,Maintenance_Cycle__c=100);
        insert equipment;
        for(Integer i=1;i<=300;i++){
            Case maintenance = new Case(Subject='Test subject'+i,Date_Reported__c = System.today(),Type='Routine Maintenance'+i,Status='New'+i,Origin='Phone'+i,Equipment__C=equipment.Id,Vehicle__c=vehicle.Id);
        insert maintenanceList;
        List<Work_Part__c> workPartList = new List<Work_Part__c>();
        for(Case caseupdate :maintenanceList){
            caseupdate.Type='routine Maintenance';
            Work_Part__c w=new Work_Part__c(Maintenance_Request__c=caseupdate.Id,Equipment__c=equipment.Id);
            caseupdate.Date_Due__c = date.Today().addDays(Integer.valueOf(equipment.Maintenance_Cycle__c));
            Database.SaveResult[] inserResult = Database.insert(workPartList);
            for(database.SaveResult sr : inserResult){
                        database.SaveResult[] updatequipment = Database.update(maintenanceListClosed);
                        for(database.SaveResult sa :updatequipment){
                                List<Case> assertNewCase=[SELECT Id FROM Case Where Equipment__c=:equipment.Id AND Vehicle__c=:vehicle.Id AND Type='Routine Maintenance' AND Subject='New Request' AND Date_Reported__c=:d ];
        catch(Exception e)
Hello Everyone,
Apex Specialist Step 4
I am getting 100% coverage but getting error. Can anyone please help where I need to change code
Class.MaintenanceRequestHelper.updateWorkOrders: line 8, column 1
Trigger.MaintenanceRequest: line 6, column 1

User-added image