Whenever case is created I have to create a incident record as well, as per my requirement I have done the field mapping as shown in class.
Problem here is one of the incident object filed BMCServiceDesk__FKCategory__c
This field has a lookup to category object, but the actual field I am trying to map from case object is Applications__c
; this is a Picklist field.
The class saved successfully, but while running the class in debug log i am getting an error like:
System.StringException: Invalid id.
Case data coming from lightning controller.
Please find my controller code below and suggest me how to achieve this:
public class ctssupportform {
public static List<Attachment> attachments;
public static final Integer DEFAULT_ATTACHMENT_NO=1;
public String sobjId {get; set;}
@AuraEnabled
public static id Savesupportform(Case casedata, String fileName, String base64Data, String contentType){
insert Casedata;
System.debug('@@@@@@@@@@@@@@@@'+Casedata);
base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
System.debug('@@@@@@@@@@@@@@@@'+base64Data );
//base64Data = 'Test';
Attachment oAttachment = new Attachment();
oAttachment.parentId = casedata.id;
oAttachment.Body = EncodingUtil.base64Decode(base64Data);
oAttachment.Name = fileName;
oAttachment.ContentType = contentType;
insert oAttachment;
Attachment oAttachment1 = new Attachment();
oAttachment1.parentId = casedata.id;
oAttachment1.Body = EncodingUtil.base64Decode(base64Data);
oAttachment1.Name = fileName;
oAttachment1.ContentType = contentType;
oAttachment1.parentId = casedata.id;
insert oAttachment1;
System.debug('@@@@@@@@@@@@@@@@@@@@'+oAttachment1);
BMCServiceDesk__Incident__c inc = new BMCServiceDesk__Incident__c();
inc.Cases__c = casedata.id;
inc.BMCServiceDesk__incidentDescription__c = casedata.Type_Of_Ticket__c;
inc.BMCServiceDesk__FKCategory__c = casedata.Applications__c; // Problem with this filed
inc.BMCServiceDesk__Service_Request_Title__c = casedata.Subject;
inc.BMCServiceDesk__FKImpact__c = casedata.Impact__c;
inc.BMCServiceDesk__FKUrgency__c= casedata.Urgency__c;
inc.BMCServiceDesk__incidentDescription__c= casedata.Description ;
inc.BMCServiceDesk__incidentDescription__c= casedata.Justification__c ;
insert inc;
System.debug('@@@@@@@@@@@@@@@@@@@@'+inc);
return casedata.id;
}
}