You need to sign in to do that
Don't have an account?
Sachin Kumar 34
Object Fields data to be transfer to the another objects fields
Hi I want to transfer some of the field’s data from Contract to CARD (Custom) object fields
Contract fields
1) DR Onsite (Formula -> Currency)
2) HR Onsite (Formula -> Currency)
3) DR Offsite (Formula -> Currency)
4) HR Offsite (Formula -> Currency)
CARD Fields
1) Onsite DR (Currency)
2) Onsite HR (Currency)
3) Offsite DR (Currency)
4) Offsite HR (Currency)
We can create multiple CARD record for one contract, so I want to populate the above field’s data whenever new CARD record will create
Eg : For Contract 1 -> Card Record 1 (Want to populate the Contract 1 fields data into the Card Record1)
For Contract 1 -> Card Record 2 (Want to populate the Contract 1 field’s data into the Card Record2)
For Contract 2 -> Card Record 1 (Want to populate the Contract 2 field’s data into the Card Record 1)
For Contract 2 -> Card Record 2 (Want to populate the Contract 2 field’s data into the Card Record 1) and so on.
What is the trigger and test class for the above problem.
Contract fields
1) DR Onsite (Formula -> Currency)
2) HR Onsite (Formula -> Currency)
3) DR Offsite (Formula -> Currency)
4) HR Offsite (Formula -> Currency)
CARD Fields
1) Onsite DR (Currency)
2) Onsite HR (Currency)
3) Offsite DR (Currency)
4) Offsite HR (Currency)
We can create multiple CARD record for one contract, so I want to populate the above field’s data whenever new CARD record will create
Eg : For Contract 1 -> Card Record 1 (Want to populate the Contract 1 fields data into the Card Record1)
For Contract 1 -> Card Record 2 (Want to populate the Contract 1 field’s data into the Card Record2)
For Contract 2 -> Card Record 1 (Want to populate the Contract 2 field’s data into the Card Record 1)
For Contract 2 -> Card Record 2 (Want to populate the Contract 2 field’s data into the Card Record 1) and so on.
What is the trigger and test class for the above problem.
trigger servicecontract on Contract (after insert)
{
Set<Id> Ids= new Set<Id>();
for (Contract cont: Trigger.new)
{
Ids.add(cont.Id);
}
List <Contract> memberInsertList = [Select Id, Daily_Rate__c, Daily_Rate_Offsite__c from Contract where Id in :Ids];
for (Contract cont : Trigger.new) {
SFDC_Service_Timecard__c stc = new SFDC_Service_Timecard__c();
stc.Daily_Rate__c = cont.Daily_Rate__c;
stc.Offsite_Daily_Rate__c = cont.Daily_Rate_Offsite__c;
memberInsertList.add(cont);
}
insert memberInsertList;
}