function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mahesh reddy 4mahesh reddy 4 

one fundamental doubt in triggers?

There are two objects.obj1 and obj2. I am writing trigger on obj1.status is a picklist field on obj1.if status=new in obj1 i can able to select type=prospect in obj2.Here objects are not related.Is it possible with triggers?
In order to do this, there should be a relation ship b/w these two objects otherwise the system will not be able to determine which record in object 2 needs to be modified. If your intension is to modify all the records of Obj2 when some record in object 1 is modified then you will not need any relation. But I am sure your's is a first case.
Vinay JVinay J
Yes, you can do it. but the question is, which record(s) are you going to update in Object 2.

If you want to update all records, then no issue. GO ahead. But if you want to modify a "specific" record in object2, then either you'll need a relationship though which, you can identify your "specific" record of object 2, or you'll need to fetch all the records in object2, go through them one by one, and based on some criteria (field value), you can decide which record(s) to update.
mahesh reddy 4mahesh reddy 4
Trigger event is before insert. writing trigger on obj1,in obj1 if status=new for that in obj2 type=prospect will select and will create a record in obi2 for each and every record in obi1.There is no relatioship? Is it possible?