I need to create a new record in the related list.. but that record should get created only after i attached a file to it...
i mean... in order to create the record in the related list of an opportunity first i'll upload the file.. and with the uploaded file name will become the record name... and the new record will be created...
You have to write a trigger on
Attachment using Eclipse. Open your Org in Eclipse then create a new trigger
where you will get a picklist to select the Attachment Object. This is only the way to write a
trigger on Attachment. Find below a sample code :
// Trigger to create a record in RelatedList_Obj__c object that is child object
of Opportunity if Opportunity have any attachment.
i think you should be more clear in your description of the problem.So that we can help.
You have to write a trigger on Attachment using Eclipse. Open your Org in Eclipse then create a new trigger where you will get a picklist to select the Attachment Object. This is only the way to write a trigger on Attachment. Find below a sample code :
// Trigger to create a record in RelatedList_Obj__c object that is child object of Opportunity if Opportunity have any attachment.
trigger TiggerName on attachment(after insert)
{
String OppAsParentId = Trigger.New[0].ParentId;
OppAsParentId = OppAsParentId.substring(0,3);
if(OppAsParentId == '006')
{
RelatedList_Obj__c ro = new(name=:Trigger.New[0].name, Opportunity_lookup__c=:Trigger.New[0].ParentId);
Insert ro;
}
}
Sir,
I am getting the following error while implementing this code....
Save error: line 8:121 no viable alternative at character ''