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

Trigger one object and query another object
Hello,
I have a object Industry (with lookup on Accounts and some text fields). Then another object Results (also linked with Accounts) that is manually imported.
Can I create a trigger that every time I create a Results record would query the Industry object and would return some of it's text fields to be copied to the Results record?
HIII
just try it will work
All Answers
Haii
i did it for account and contact objects instead of custom objects
try this one....
trigger account1 on Account (after insert,after update) {
List<Contact> con=new List<Contact>();
List<Account> acc=[select id,name from account where id in : trigger.new ];
if(Trigger.isInsert)
{
for(account c:acc)
{
con.add(new Contact(lastname=c.name));
insert con;
}
}
if(Trigger.isUpdate)
{
List<Account> acct=[select id,name from account where id in : trigger.old];
for(account c:acct)
{
con.add(new Contact(lastname=c.name));
insert con;
}
}
}
Do you think it will work (with some modifications) for this example:
When a Result entry (ResultField1 = "A", ResultField2 = "B") is created, the trigger would check in Industry objects if there any record with IndustryField1 = "A", IndustryField2 = "B" and would copy IndustryField3 value to ResultField3.
HIII
just try it will work