You need to sign in to do that
Don't have an account?

Ideas Plsss
I have an object called "Lease".When i create a record in Lease it gets saved.I should have a button "Generate Office " in the record which automatically creates an office record which is exactly same as record created earlier in Lease
In " office" all the fields which are there in "lease" are present and also they are formula fields
I am in a confusion as i didnot understand d req properly or how do i need approach
Do i need to visual force page for the button
After insert Trigger on Lease may help
but every time when i change a field in lease is the particular field in office also updated
Next
How can i create an automatic Office record when a lease record is created
Use afterinsert trigger on lease to create new office record
You can check this url for how to do it
http://teachmesalesforce.wordpress.com/2011/05/16/trigger-to-create-a-new-record/
Similarly you can update the office object by using the afterupdate trigger on lease
Trigger to create new record works fine but whenever i make changes to the Lease Recorrd the newly created office record is not getting updated. If i keep a after update then for even making a small update in the Lease record a new duplicate office record is being created
what are you doing in update trigger?
Are you inserting a new record?
You need to search for the record from office object and update it.
Pls note : Make sure you bulkify your trigger. Maybe if you post the code someone could help you with that
This link could also help
http://forceschool.blogspot.com/2011/05/writing-apex-trigger-save-limits-in.html
This is the trigger which i wrote so far
trigger createOffice on Lease__c(after insert) {
List<Offices__c> off = new List<Offices__c>();
for (Lease__c newLease: Trigger.New){
off.add (new Offices__c(
Name = newLease.Office_Id__c,
Address__c = newLease.Address__c,
City__c = newLease.City__c,
State__c = newLease.State__c));
}
insert off;
}