0

I am trying to test Apex code that was developed to provide a @RestResource for Kimble Event information. In order to test it I either need to insert the event through Apex or us SeeAllData=true. I would rather do the former. However, when I try to insert all of the elements to create a Kimble Event I get an error from a Trigger within Kimble. Since it is a managed application I am not sure how to see what I need to do to insert the correct information.

Here is the error message:

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, KimbleOne.ResourcedActivity_A_I: execution of AfterInsert caused by: KimbleOne.HandledException: ERR:Invalid or missing ResourcedActivityType Other (KimbleOne): []

Here is the code in my test class that tries to insert the Kimble Event:

KimbleOne__ResourcedActivityType__c kimAT= new KimbleOne__ResourcedActivityType__c(name='test');
    insert kimAT;
    KimbleOne__ResourcedActivity__c kimRACT=new KimbleOne__ResourcedActivity__c(name='testkrc',KimbleOne__ResourcedActivityType__c=kimAT.id);
    insert kimRACT;
    KimbleOne__ActivityAssignment__c actAssign= new KimbleOne__ActivityAssignment__c(name='test',KimbleOne__ResourcedActivity__c=kimRACT.Id);
    insert actAssign;

The error message fails on the line that tries to insert kimRACT. kimAT inserts just fine. And without the Resourced Activity the Activity Assignment fails.

Here is the code within the class the checks for the Activity Assignment:

@RestResource(urlMapping='/DataEvent/*')

global class KimbleEventManager {

@HttpGet
global static KimbleOne__ActivityAssignment__c getEventById() {
    RestRequest request = RestContext.request;
    // grab the EventId from the end of the URL
    String eventId = request.requestURI.substring(
      request.requestURI.lastIndexOf('/')+1);
    KimbleOne__ActivityAssignment__c result =  [select ID, Account_Id__c,Resource_Name__c,KimbleOne__ResourceUser__c,KimbleOne__StartDate__c,Number_of_Attendees__c,Workshop_Name__r.Name,Service_Type__c,Account_Name__c,KimbleOne__Location__r.name,(select ID,Capability_Type_Name__c,Name from KimbleOne__RequiredCapabilities__r where KimbleOne__IsMandatory__c=TRUE)  from KimbleOne__ActivityAssignment__c where event_id__c =:eventid];
    return result;
}

}

Any idea from the error message what I need to do? Is there another way to test this class?

4
  • 1
    The error suggests a type called "Other" is needed?
    – Phil W
    Commented Jan 13, 2023 at 8:09
  • Thanks Phil, but I haven't been able to find where in ResourcedActivityType this would go. I tried KimbleOne__ResourcedActivityType__c.Name field and it didn't work. I have no idea where else this would go and unfortunately don't have access to Kimble documentation. Commented Jan 13, 2023 at 20:32
  • You tried to change the KimbleOne__ResourcedActivityType__c construction to pass Name='Other'?
    – Phil W
    Commented Jan 13, 2023 at 22:36
  • Yup. I tried that and it didn't work. Commented Jan 18, 2023 at 1:26

0

You must log in to answer this question.

Browse other questions tagged .