I want to achieve the same functionality as that of account team in project(Custom object) using trigger . For this I have made a new custom object as projectteam and added lookup of user as well as project. and also tried a code but not getting if it is correct or not
This is my code:
trigger projectteam on Projectteam__c (after insert) {
if(trigger.IsInsert){
Projectteam__c project=new Projectteam__c();
List<Projectteam__share> projectshares=new List<Projectteam__share>();
for(Projectteam__c proj:trigger.new){
Projectteam__share projRecord=new Projectteam__share();
projRecord.ParentId=proj.Related_Project__c;
projRecord.UserOrGroupId =proj.Team_member__c;
projRecord.AccessLevel = 'read';
projRecord.RowCause = 'Manual';
projectshares.add(projRecord);
}
insert projectshares;
}
}
and I am getting this error : Review all error messages below to correct your data.
Apex trigger projectteam caused an unexpected exception, contact your administrator: projectteam: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Parent ID: id value of incorrect type: a032v00002tCFh8AAG: [ParentId]: Trigger.projectteam: line 13, column 1
can anyone suggest what should i do?