You need to sign in to do that
Don't have an account?
Marypearl Parnell
Apex trigger - Travel Request that isn't exempt
May I get some assitance with my Apex Trigger?
The trigger should fire if the Travel Request record isn't an exemption. This is indicated by a check box:
The trigger should fire if the Travel Request record isn't an exemption. This is indicated by a check box:
trigger CreateTask on Travel_Request__c (before insert) { list<task> listtask = new list<task>(); for (travel request = trigger.new) {if (Exemption == 'True') {task NewTask = new task(); NewTask.subject = 'Create Call Report'; NewTask.duedate = system.today().adddays(7); NewTask.whatID = Id; listtask.add(NewTask); } } if (listtask.size()>0) insert listtask; }
Code is here
Please modify as below
To provide a particular contact or lead or opp or account id - please retrieve that particular record out side of for loop. For example I am retrieving coontact.
ID conid = [select id from contact where Lastname = 'xyz' limit 1].id;
Now replace "NewTask.whatID = Id;" with
NewTask.whatID = conid ;
Please mark as best answer if the above helps..!!!
Feel free to ask if you have any doubts.
Thanks to you all for your input!
Do let us know how it went.
Please feel free to close the thread by marking a Best Answer to help someone else in the same quandary.
Thanks,
Shruti