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
Daniel FullerDaniel Fuller 

How do I capture a new Case Record Id with a Javascript Event?

Good morning everyone. 

I currently have a somewhat complex problem that we are facing. We are currently trying to track Javascript events on the standard Case detail page in the service console. For example, when a user clicks the "New Case" button, we want to get a record in a Time Tracking object showing that the user clicked that button. We then want to track the creation of that new case (clicking the "Save" button) as a closing event for that New Case opening event in the Time Tracking custom object. We are currently doing this with a Javascript Chrome extension using the Ajax toolkit.

The problem we are having is that we cannot figure out a way to capture the Case Record Id of the newly created case and assign that Case Record Id to the New Case opening event record in the Time Tracking object. We could assign the record id successfully if we could somehow capture the Id. The problem is that the New Case page in the console is an iFrame that is separate from a different iFrame that loads once the "Save" button is clicked and you are taken to the Case Detail page for that new case. At that point, we lose the context of the New Case iFrame. 

Would there be any way to capture that Record Id when the Save button is clicked or to somehow capture that new record Id and then associate it to the correct New Case record in the Time Tracking custom object?