+ Start a Discussion
Karthikeyan ChandranKarthikeyan Chandran 

Need help on trigger

Hi,

Using trigger, I just want to auto create new contract records under the opportunity when ever the Opportunity record record type is set to (Record Type1 or Record Type2 or Record Type3) and Opportunity Stage = Closed Won. also the Contract Record owner will be same as the Opportunity Owner for the auto created record.

Thanks & Regards,
Karthikeyan Chandran
Best Answer chosen by Karthikeyan Chandran
CongnizentCongnizent
Hi Karthikeyan ,

On go to opportunity . New Trigger

(After insert )
{
if(Trigger.new.Stage='Close won' && (Trigger.new.recordType.Name='a'||Trigger.new.recordType.Name='b'||Trigger.new.recordType.Name='c'))
Contract c=new Contract (Related_Opportunity__c =oppty.id);

insert c ;
}

(After update )
{
if(Trigger.new.Stage='Close won' && (Trigger.new.recordType.Name='a'||Trigger.new.recordType.Name='b'||Trigger.new.recordType.Name='c'))
Contract c=new Contract (Related_Opportunity__c =oppty.id);

insert c ;
}

All Answers

CongnizentCongnizent
Hi Karthikeyan ,

On go to opportunity . New Trigger

(After insert )
{
if(Trigger.new.Stage='Close won' && (Trigger.new.recordType.Name='a'||Trigger.new.recordType.Name='b'||Trigger.new.recordType.Name='c'))
Contract c=new Contract (Related_Opportunity__c =oppty.id);

insert c ;
}

(After update )
{
if(Trigger.new.Stage='Close won' && (Trigger.new.recordType.Name='a'||Trigger.new.recordType.Name='b'||Trigger.new.recordType.Name='c'))
Contract c=new Contract (Related_Opportunity__c =oppty.id);

insert c ;
}
This was selected as the best answer
Karthikeyan ChandranKarthikeyan Chandran
Hi,

Thanks for the quick response, let me with the above suggestion.
CongnizentCongnizent
Please mark it best answer if it really helps you .
if you face any problem . please ask .

Thanks