• nani812
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

Hi,

 

I have a custom object Frame_Agreements__c with two lookupfields(Account, Contract) to Account and Contract. I have written a trigger to insert the records in Frame_Agreements__c as soon as new contract is created. But its not working...Can anyone help me..

 

 

trigger ConRelate on Contract (after insert, after update){
//List<Contract> listContracts=new List<Contract>;
List<Frame_Agreement__c> Lac = new List<Frame_Agreement__c>();
Set<ID> Cid = new Set<ID>();
for(Contract ctr : Trigger.New)
{
CId.add(ctr.Id);
}
List<Contract> cont = [select ContractNumber,Contract.Account.Name from contract where Id in :CId];

for (Contract fContract : cont) {

Frame_Agreement__c fac = new Frame_Agreement__c();
//fac.Name = fContract.Name;
//fac.Id = fContract.Id;
fac.Account_Name__c= fContract.Account.Id;
fac.Contract_Name__c=fContract.Id;

Lac.add(fac);
}

/*if (cont.isEmpty() == false) {
update cont;
}*/
}

 

  • September 01, 2013
  • Like
  • 0

Hi,

 

I have a custom object Frame_Agreements__c with two lookupfields(Account, Contract) to Account and Contract. I have written a trigger to insert the records in Frame_Agreements__c as soon as new contract is created. But its not working...Can anyone help me..

 

 

trigger ConRelate on Contract (after insert, after update){
//List<Contract> listContracts=new List<Contract>;
List<Frame_Agreement__c> Lac = new List<Frame_Agreement__c>();
Set<ID> Cid = new Set<ID>();
for(Contract ctr : Trigger.New)
{
CId.add(ctr.Id);
}
List<Contract> cont = [select ContractNumber,Contract.Account.Name from contract where Id in :CId];

for (Contract fContract : cont) {

Frame_Agreement__c fac = new Frame_Agreement__c();
//fac.Name = fContract.Name;
//fac.Id = fContract.Id;
fac.Account_Name__c= fContract.Account.Id;
fac.Contract_Name__c=fContract.Id;

Lac.add(fac);
}

/*if (cont.isEmpty() == false) {
update cont;
}*/
}

 

  • September 01, 2013
  • Like
  • 0