编译此触发器时出现此错误,
错误:编译错误:期待冒号,找到' vInvReq.JDRF_Location__c'在第16栏第13栏
我的代码如下,问题在于此行WHERE Name=vInvReq.JDRF_Location__c]);
谢谢,感谢任何帮助,
trigger TgrInventoryRequestAfter on Inventory_Request__c (after update) {
//set<Id> JDRFLocationId = new set<Id>();
//List<Inventory_Request__c> vLstInventory_Request= new List<Inventory_Request__c>();
List<JDRF_Location__c> locaList = new list<JDRF_Location__c>();
for (Inventory_Request__c vInvReq:trigger.new)
{
if(vInvReq.Request_Status__c == 'Approved' && vInvReq.Inventory_Type__c == 'Bag of Hope')
{
locaList=
new list<JDRF_Location__c> ([Select Name,Current_boh_Inventory__c from JDRF_Location__c
WHERE Name=vInvReq.JDRF_Location__c]);
Integer sumCBOH = vInvReq.Units_Requested__c+ locaList.Current_boh_Inventory__c ;
locaList.Current_boh_Inventory__c= sumCBOH;
}
}
答案 0 :(得分:2)
将=:
放在字段名称和变量之后的WHERE
之后:
WHERE Name=:vInvReq.JDRF_Location__c
原因如下:
https://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_variables.htm