You need to sign in to do that
Don't have an account?
Praetorian65
Error: Compile Error: Initial term of field expression must be a concrete SObject
Error: Compile Error: Initial term of field expression must be a concrete SObject: Datetime at line 53 column 61
Apex is driving me up the wall. I am trying to convert from a datetime to a date. Line 53 is in bold. It will not let me use licenseArray[i].StartDate to access the date (licenseArray is an array of License objects). I have successfully used licenseArray[i].StartDate in the creation of a custom object (License__c) but I need to change this object to have Date fields instead of DateTime. I am getting the data from a webservice which provides DateTime. StartDate and EndDate can both be null. How can I fix this?
Code:
try{ While(licenseArray.Size() > 0) { for(Integer i = 0; i < licenseArray.Size(); i++) { date endD; date startD; if(licenseArray[i].StartDate != null) { //DateTime startDateTime = licenseArray[i].StartDate; Integer startYear = licenseArray[i].startDate.Year; Integer startMonth = licenseArray[i].startDate.Month; Integer startDay = licenseArray[i].startDate.Day; startD = date.newinstance(startYear,startMonth,startDay); } if(licenseArray[i].EndDate != null) { DateTime endDateTime = licenseArray[i].EndDate; Integer endYear = endDateTime.Year; Integer endMonth = endDateTime.Month; Integer endDay = endDateTime.Day; endD = date.newinstance(endYear,endMonth,endDay); } License__c newLicense = new License__c(ContactName__c = licenseArray[i].ContactName, NetworkCode__c = licenseArray[i].NetworkCode, Period__c = licenseArray[i].Period, Number__c = licenseArray[i].Number_x, EndDate__c = endD, StartDate__c = startD); myList.Add(newLicense); if(myList.Size() == 1000) { myListList.Add(myList); myList = new List<License__c>(); } } index = index + count; licenses = data.GetLicenseData(index,count); licenseArray = licenses.License; } } catch (Exception ex) { }
Jeremy Kraybill
Austin, TX
Jeremy Kraybill
Austin, TX