function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jim MorgandoJim Morgando 

Apes Test Class

I'm trying to create a Test Apex class but getting a
Error: Compile Error: Expression cannot be assigned at line -1 column -1
@isTest
public class ICNFILL {
Public static void validate() {
       BMCServiceDesk__Incident__c.ICN_Circuit_No__c ='02ELP-NW5.2646';
   
      
           
    }
}
The trigger that is for this auto filles fields on the Incident ticket in Remedyfoce.

 
Pankaj_GanwaniPankaj_Ganwani
Hi,

Please create an instance of this BMCServiceDesk__Incident__c and then assign the value to instance:

@isTest
public class ICNFILL {
Public static void validate()

       BMCServiceDesk__Incident__c obj = new BMCServiceDesk__Incident__c();
       obj.ICN_Circuit_No__c ='02ELP-NW5.2646';          
    }
}
Jim MorgandoJim Morgando
Well, now I'm getting this ERROR: When trying to validate it in Production.

ICNFILL.validate(), Details: System.StringException: Invalid id: 02ELP-NW5.2646 Class.ICNFILL.validate: line 4, column 1

@isTest
private class ICNFILL {
    static testMethod void validate() {
        BMCServiceDesk__Incident__c b = new BMCServiceDesk__Incident__c(ICN_Circuit_No__c ='02ELP-NW5.2646',
       BMCServiceDesk__FKClient__c = 'jim.morgando@illinois.gov', BMCServiceDesk__FKCategory__c = 'Hardward');
      
       insert b;
   
    }
}






 
Pankaj_GanwaniPankaj_Ganwani
Hi,

Is ICN_Circuit_No__c a lookup field? If so, they you cannot directly assign any string to it. You will have to create its parent record first and then assign the Id of that parent record to it.

Please let me know if this makes sense.
 
Jim MorgandoJim Morgando
Thanks, so when you say create a parent record do you mean like in Remedyforce the Incident # for that ICN Field? Thanks, Jim Morgando State of Illinois - Central Management Services Bureau of Communication and Computer Services Enterprise Applications & Architecture - Workflow 120 West Jefferson, Springfield, Illinois 62702 Office: (217) 785-6788 Blackberry: (217) 720-9150 jim.morgando@illinois.gov P Think Green. Please consider the environment before printing.
Jim MorgandoJim Morgando
Thanks, that worked… one more thing I order for the Validate to work I have to add an update field to the Test Class anythoughts on what I have wrong below?? Will not save @isTest private class ICNFILL { static testMethod void validate() { BMCServiceDesk__Incident__c b = new BMCServiceDesk__Incident__c(ICN_Circuit_No__c ='a0AM0000005KitpMAC', BMCServiceDesk__FKClient__c = 'jim.morgando@illinois.gov', BMCServiceDesk__FKCategory__c = 'Hardward'); insert b; update ICNAendRTC__c ='RTC2'; } } Thanks, Jim Morgando State of Illinois - Central Management Services Bureau of Communication and Computer Services Enterprise Applications & Architecture - Workflow 120 West Jefferson, Springfield, Illinois 62702 Office: (217) 785-6788 Blackberry: (217) 720-9150 jim.morgando@illinois.gov P Think Green. Please consider the environment before printing.
Jim MorgandoJim Morgando
I tried this one: I get ERROR: Error: Compile Error: line breaks not allowed in string literals at line 9 column -1 @isTest private class ICNFILL { static testMethod void validate() { BMCServiceDesk__Incident__c b = new BMCServiceDesk__Incident__c(ICN_Circuit_No__c ='a0AM0000005KitpMAC', BMCServiceDesk__FKClient__c = 'jim.morgando@illinois.gov', BMCServiceDesk__FKCategory__c = 'Hardward'); insert b; BMCServiceDesk__Incident__c c : [BMCServiceDesk__FKIncident__c = 'a1NM0000002hygbMAA']; update ICN_Circuit_No__c ='a0AM0000005KitpMAC; } } Thanks, Jim Morgando State of Illinois - Central Management Services Bureau of Communication and Computer Services Enterprise Applications & Architecture - Workflow 120 West Jefferson, Springfield, Illinois 62702 Office: (217) 785-6788 Blackberry: (217) 720-9150 jim.morgando@illinois.gov P Think Green. Please consider the environment before printing.