• Sourajit Mohanty
  • NEWBIE
  • 5 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies

I need to have Order line items under the Products object,
as one Order might have multiple products.

Please guide me how it can be related while creating Orders

Thanks

A developer has the following trigger that fires after insert and creates a child Case whenever a new Case is created.
List<Case> childCases = new List<Case>();
for ( Case parent : Trigger.new )
Case child = new Case(Parentid = parent.id, Subject = parent -Subject);
childCases.add( child );
insert childCases;
What happens after the code block executes?

A.multiple child cases are created for each parent in trigger.new
B.Trigger enters infinite loop and eventually fails
C.Child case is created for each parent case in trigger.new
D.The trigger fails if subject field on parent is blank
can any one explain about this .

In case of Master-Detail relationship, on Update of master record can we update the field of child record using workflow rule?

Below lines taken from Salesforce Apex Code Developer's guide:
'if you update or delete a record in its before trigger, or delete a record in its after trigger, you will receive a runtime
error.This includes both direct and indirect operations. For example, if you update account A, and the before update trigger
of account A inserts contact B, and the after insert trigger of contact B queries for account A and updates it using the DML
update statement or database method, then you are indirectly updating account A in its before trigger, and you will receive
a runtime error'


But I can update the Contact description in the before update trigger. Below is the code:

trigger triggerAllContextVariableCheck on Contact (before update, after update, before insert, after insert) {
    if(Trigger.isBefore){
     if(Trigger.isUpdate){
         for(Contact c: trigger.new){
             c.Description='Before Update'; 
         }}}
}

What I am missing? Above code is updating the Contact record in it's before trigger but the statement in the book says something else.

Please explain.