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
VRKVRK 

Trigger: after create record in custom object , create Task under contact object

Hi all,
scenario : i have custom object  name : 'Travel'  and fileds are firstname_c,lastName_c,age_c, dob_c..
third party will send data to Travel object .
so my requirement is , when record created in Travel object , immediatly Task created under contact object and update fields firstname_c,lastName_c,age_c, dob_c. and status is Completed.
How can i write Trigger code for this?
Shawn Reichner 29Shawn Reichner 29
sekhar123,

It is not listed above, but do you have a lookup field on your custom object to the Contact object?

If not, how will you know which contact to create a task for? 

If you do have this lookup relationship, you could run your trigger to after create, perfrom a SOQL search to find the matching contact if one exists, and if not create one using the date you have (although you may want to start grabbing email and phone number for this process) and in that same create call after your contact has been retrived or created, you can then create your task and assign to the contact you just created or found. 

Hope that makes sense, and if I am completely off, please provide some more information around your request so that we cna help further. 

Shawn
VRKVRK
Hi Shawn,
thanks for your response...
let me explain clear with my requirement.....
i have custom object  ivr_journey and created fields of Seq_Member_ID__c,Caller_ID__c,Start_Date_Time__c,End_Date_Time__c,Date_of_Birth__c.... and IVR_Journey__c(lookup field on Contact).
and i created same fields under contact---> openActivities( under IVR Record Type)
Now, my requirement is , when record created in custom object  'ivr_journey' ,   immediatly  task created in  Contact --->Activity History  with update fields Seq_Member_ID__c,Caller_ID__c,Start_Date_Time__c,End_Date_Time__c,Date_of_Birth__c.....
for example:
Allen created record in 'IVR_Journey' with details of  11111(seq_member_id), 22222(caller_id), 2018-03-01(start_date), 2018-05-01(end_date), 1989-02-01(date_of_birth), then immediatly activity history will be created and update same details for the Contact 'Allen'.
can you pls provide sample data for this....Thanks