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

Basic Trigger HELP !
I am trying to write a trigger to do the following..
I have a custom object called Project with the API Name of - pse__Proj__c
I have another custom object called Budget with the API Name of - pse__Budget__c
What I want to do with the trigger is..
When a new project is created I want the project name to automatically fill a field on the budget object called project. The project field on the budget object is a lookiup field to the project object and has the API name of pse__Project__c.
Later on I want to also incorporate the trigger to update a field on the budget object called Amount, that has the API name of
pse__Amount__c with the value found on the Project object in the field called Prouct Budget MAP with the API name of Product_Budget_MAP__c. That can wait but I do need the first step implemented in order to move forward.
HERE IS WHAT I HAVE SO FAR... Any help is much appreciated!!
trigger updateBudgetProject on pse__Budget__c (after insert){
List<pse__Budget__c> BudgetToUpdate = new list<pse__Budget__c>();
for(pse__Budget__c bud : [select Id, pse__Proj__c.Id From pse__Budget__c Where Id IN : trigger.newMap.keyset()]){
bud.pse__Project__c = bud.pse__Proj__c.name;
BudgetsToUpdate.add(bud);
}
if(!BudgetsToUpdate.isEmpty())
update BudgetsToUpdate;
I have a custom object called Project with the API Name of - pse__Proj__c
I have another custom object called Budget with the API Name of - pse__Budget__c
What I want to do with the trigger is..
When a new project is created I want the project name to automatically fill a field on the budget object called project. The project field on the budget object is a lookiup field to the project object and has the API name of pse__Project__c.
Later on I want to also incorporate the trigger to update a field on the budget object called Amount, that has the API name of
pse__Amount__c with the value found on the Project object in the field called Prouct Budget MAP with the API name of Product_Budget_MAP__c. That can wait but I do need the first step implemented in order to move forward.
HERE IS WHAT I HAVE SO FAR... Any help is much appreciated!!
trigger updateBudgetProject on pse__Budget__c (after insert){
List<pse__Budget__c> BudgetToUpdate = new list<pse__Budget__c>();
for(pse__Budget__c bud : [select Id, pse__Proj__c.Id From pse__Budget__c Where Id IN : trigger.newMap.keyset()]){
bud.pse__Project__c = bud.pse__Proj__c.name;
BudgetsToUpdate.add(bud);
}
if(!BudgetsToUpdate.isEmpty())
update BudgetsToUpdate;
Kris - you wanted this to fire when a new project is created, but your trigger is on the budget object? What is the sequence of events you're trying to include with this trigger?