Timeline for How do I take out the DML statements out of the loop?
Current License: CC BY-SA 4.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 15, 2020 at 14:36 | comment | added | manb | In the above example I am create new course offerings from a single course offering. Since the new course offerings are a copy of that one course offering, I want to increment a number in the name of the newly created course offerings. Example: Old Course offering Name - HelloWorld-1-test. New Course offering Names should be: HelloWorld-2-test, HelloWorld-3-test, HelloWorld-4-test. Since I am bulk inserting, how can I go about this ? | |
Sep 11, 2020 at 13:53 | comment | added | sfdcfox♦ | @manb Then your key is (presumably) incorrect. You should inspect what you're putting into the key. | |
Sep 11, 2020 at 13:52 | comment | added | manb | And thank you for explaining the above. I read up on some stuff. It makes sense to me now. You are great!! | |
Sep 11, 2020 at 13:51 | comment | added | manb | I don't know why, but 'insert courseOfferings.values()', is inserting all the values with same name, even though they are different. | |
Sep 11, 2020 at 13:47 | vote | accept | manb | ||
Sep 11, 2020 at 13:42 | comment | added | sfdcfox♦ | @manb The map keys should not change, or you get unexpected behavior. The ID we're getting here is from the values in the map after insertion. | |
Sep 11, 2020 at 12:59 | comment | added | manb | so do you mean, the ID which is generated on inserting the values associated with the keys will be the same on the keys as well? And when I have to associate the enrollments to those key ID's? | |
Sep 10, 2020 at 14:55 | comment | added | manb | Trying to make sense of it and testing it out right now. Will get back to you. Thank you :D | |
Sep 10, 2020 at 14:53 | comment | added | sfdcfox♦ | @manb The keys should not be changed. We're creating new records in memory, then inserting those; they are still associated to the original keys, which we then use to get the enrollments. | |
Sep 10, 2020 at 14:48 | comment | added | manb | I was still editing the above. please can you check @sfdcfox | |
Sep 10, 2020 at 14:46 | comment | added | manb | So just to clarify, the new course offerings are being made from one existing course offering which have the related course enrollments. Then those course enrollments are being divided into the new created course offerings from that one course offering. What I am not able to understand is that, the Id's for the newly created course offerings will be created on insert, right ? But you are using the keys to associate the course enrollments. Which isnt making sense, because those keys havent recieved their ID's yet since the havent been inserted. What you have inserted is the values. | |
Sep 10, 2020 at 14:33 | history | answered | sfdcfox♦ | CC BY-SA 4.0 |