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
LBartonLBarton 

Identity Field in a Query?

I am not sure how to get an identity field to work in a function in an apex class.  I have:

 

public void UpdateSupportFields(ID OpportunityID, string SupportConsultant, string OppStatus ......[other fields])

 

 Opportunity[] op=[SELECT ID, Support_Consultant__c, ...., Support_EXT_Name_Test__c, Support_Network__c,  Support_Last_Update_Live__c, Support_Last_Update_Test__c from Opportunity Where ID= :OpportunityID LIMIT 1];

 

 

//this next part is always 0 even if I have a valid Opportunity.ID


        System.debug('Opsize: ' + op.size());

        if (op.size() > 0)

 

When I use  a test method on this, I have the following:

 

   id MyID =  '0068000000OyuwjAAB';   

        mySupportUpdate.UpdateSupportFields(myID, 'Mr. SupportConsultant', 'Cancelled', MyDate , MyDate , MyDate , .....) ;

Can I have an ID field like the above or is there something else the matter?  I just want to be able to have the selection be for the Opportunity ID I pass into the function.  Thanks!  I just can't get rows when testing.

 

 

Best Answer chosen by Admin (Salesforce Developers) 
LBartonLBarton
Never mind.  There is no data at all in the Test Sandbox so I will have to create some to get this working.  Sorry about that.  The problem is solved.