You need to sign in to do that
Don't have an account?
George Adams
"Required fields are missing" error on insert
Hi all,
I'm getting the following error with a Detail Page Button that runs an apex class.
Here is the apex class:
Is it because I'm using a List to store the values to be inserted (and this can't hold the assigned ID)?
Thanks!
I'm getting the following error with a Detail Page Button that runs an apex class.
Here is the apex class:
global class logHearingResult{ WebService static Id changePriority(Id currentCase) { //new set to hold current case Ids Set<Id> caseIds = new Set<Id>(); //add current case Id to above set (currentCase is passed from javascript button) caseIds.add(currentCase); //new list to hold cases with the current case's Id List<Case> results = [ select Id, Priority from Case where Id in :caseIds ]; //set caseIdToReturn to first Id in results list (this is just for test where popup from button displays current case Id) id caseIdToReturn = results.get(0).Id; List<Hearing_Result__c> resultsToInsert = new List<Hearing_Result__c>(); //work based on current case for (Case c : results){ c.Priority = 'High'; Hearing_Result__c ins = new Hearing_Result__c (ContactID__c = c.ContactId); resultsToInsert.add(ins); } insert resultsToInsert; update results; return caseIdToReturn; } }On line 27, I am assigning the ContactID__c value to the same contact ID that is associated with the current case. This is why I'm confused by the error.
Is it because I'm using a List to store the values to be inserted (and this can't hold the assigned ID)?
Thanks!
Looks like I needed to query for ContactId on the SOQL query. Otherwise "c.ContactId" was a blank value, so it was giving an error saying no ID was assigned.