這意味着你的查詢沒有返回結果(所以列表是空的,然後當投入Sobject時,沒有物品需要)。
qName = [select Row_Id__c, Name from Ccon__c where Id = :ApexPages.currentPage().getParameters().get('id')].Row_Id__c;
我會做這種方式(以確保在任何情況下,我會從我的查詢中獲取價值,如果我的ID是有效的):
Id tempID = null;
if(ApexPages.currentPage().getParameters().get('id') != null)
{
tempId = ApexPages.currentPage().getParameters().get('id');
}
else{ //Error management
}
List<Ccon__c> recordsToProcess = new List<Ccon__c>();
if(tempID != null)
{
recordsToProcess = [select Row_Id__c, Name from Ccon__c where Id = :tempID];
}
else{ //Error management
}
//qName Declaration
if(!recordsToProcess.isEmpty())
{
qName = recordsToProcess[0].Row_Id__c;
}
else{ //Error management
}
if(qName == null)
{
//Error management
}
如果您有更多疑問,請隨時向問。但作爲一種最佳實踐,您可能始終確保您的列表在獲取記錄返回之前不是空的。
謝謝 HqSeO