You need to sign in to do that
Don't have an account?
Santi Ram Rai
Trigger in lookup relationship(Value from Pick-list)
Hi everybody,
i) I have custom Objests: (Project, Project Task)
ii) They have lookup relationship.[Project can have many Project Tasks]
So, i have custom field called Status Type PickList(Active,Inactive,Closed) in Object Project.
Now, my Logic is: When the Project Task is created under Project the Status should change to Active.
This is my Trigger:
But i have this error:
i) I have custom Objests: (Project, Project Task)
ii) They have lookup relationship.[Project can have many Project Tasks]
So, i have custom field called Status Type PickList(Active,Inactive,Closed) in Object Project.
Now, my Logic is: When the Project Task is created under Project the Status should change to Active.
This is my Trigger:
trigger StatusActive on Project__c (after insert) { for (Project__c fc: Trigger.new) { if(fc.Project__c.Project_Task_Name__c != "") fc.Status__c = 'Active'; } }
But i have this error:
Try with ' instead using " .
Regards
Use single quote instead of double quotes in line no 4.
Now i ahve this error:
You trigger is on Project object and your logic is that whenever a Project Task record gets created it updates Project record.
First you need to write trigger on Project Task object and on Insert event you have to implement your logic to update related Project record as Active.
-Thanks,
TK
[Project] onr-to-many [Project Task]
I am new in salesforce, do you ahve any example, which related to this issue?
You have to write a trigger on Child object(i.e: Project Task).
Replace your exact field and object names in the above code.
1. Project_Task__c == Child object name
2. List<Project__c> prjList = new List<Project__c>(); // This should be parent object name.
3. fc.Project__c // It should be the lookup field API name in the Project task object.
I have implemented, but i have this error:
I got this error.
"Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger StatusActiveTrigger caused an unexpected exception, contact your administrator: StatusActiveTrigger: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.StatusActiveTrigger: line 7, column 1"
This is my code:
i) Project__c, Project_Task__c are two custom object.
ii) Status__c is field in object Project__c.
iii) and 'Active' is picklist value in field Status__c.
Please can you help me to fix this.