You need to sign in to do that
Don't have an account?

Trigger.new error
Hey all,
I've just finished going through the DF '09 workbook for building a trigger. I'm now applying what I've learned to my real world example. This is what I'm trying to do.
On my asset object I have a new lookup relationship to a my custom object: Support Contracts. I want to return a list of assets which have the same support contract ID as the current asset.
Do I even need the Trigger.new? If not then What do I put as the where clause?
Error message:
Error:
Compile Error: Invalid bind expression type of SOBJECT:Asset for Id
field of SObject Support_Contract__c at line 7 column 42
[[Line 7 column 42 is where the word "Trigger" starts]]
Code so far:
trigger updateSupportContractAmount on Asset (after update) {
//gets the list of Assets
list<Asset> assetItems =
[Select a.List_Price__c, a.Quantity, a.Total__c
from Asset a
where a.Exclude_from_Renewals__c = False
and a.Support_Contract__r.id IN :Trigger.new
];
}
Thanks mba75 however I'm getting the error: "Error: Compile Error: expecting a semi-colon, found 'ids' at line 2 column 8" This is a straight copy from what you gave. I'm clueless on trying to figure out what the syntax it's expecting. If I add the semi-colon where it wants it continues to give other syntax errors about missing angle bracket and so on.
Code reformated
trigger updateSupportContractAmount on Asset (after update) { set ids = new set(); for (Asset ass : trigger.new ) { ids.add(ass .Support_Contract__c); } list assetItems = [Select a.List_Price__c, a.Quantity, a.Total__c from Asset a where a.Exclude_from_Renewals__c = False and a.Support_Contract__r.id IN :ids ]; }