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
FastSnailFastSnail 

After Insert BULK Trigger using the Id of the newly created records to populate a field?

Hello everyone,
I am strugling with the following.  I want to populate a URL field that will include the Id of the inserted record through a Trigger.
It has to be an AFTER Insert trigger as it uses the Id of the inserted object.
I need this trigger to run in BULK (more tne 200 at a time), so I cannot use SOQL inside the trigger
How do you achieve this?
Thanks in advance for your herp.
Jerome
Best Answer chosen by FastSnail
Eli Flores, SFDC DevEli Flores, SFDC Dev
Can you use a formula field for this?

Check http://help.salesforce.com/HTViewHelpDoc?id=customize_functions_a_h.htm&language=en_US (http://help.salesforce.com/HTViewHelpDoc?id=customize_functions_a_h.htm&language=en_US)

and search on HYPERLINK for how to use the HYPERLINK function in a text formula field. Assuming there's a reasonably finite number of urls, you should be able to craft a formula field to create the URL and not have to hastle trying how to do it via an after trigger

All Answers

Eli Flores, SFDC DevEli Flores, SFDC Dev
Can you use a formula field for this?

Check http://help.salesforce.com/HTViewHelpDoc?id=customize_functions_a_h.htm&language=en_US (http://help.salesforce.com/HTViewHelpDoc?id=customize_functions_a_h.htm&language=en_US)

and search on HYPERLINK for how to use the HYPERLINK function in a text formula field. Assuming there's a reasonably finite number of urls, you should be able to craft a formula field to create the URL and not have to hastle trying how to do it via an after trigger
This was selected as the best answer
FastSnailFastSnail
THANK YOU Eli.  You are right. I did not do this at first because I needed a Ramdom element in my URL and I used Apex to do this in my trigger, BUT I was able yesterday to use a Random element in my URL Formula Field using SFDC Autonumber, and this is a much cleaner solution. Thanks again, Jerome