This is a great question and seems to be pretty common. So I have provided a screenshot below to help users of Thinkorswim to determine which quote columns contain code and which ones do not.
If the quote column does not contain any code that means the values are computed internally and are not available through any custom script we can write.
Along with the screenshot I will provide the following link which shows all of the available script functions related to Stock Fundamentals:
There are 20 items available in this category at this time and none of them provides access to the Market Cap of individual stocks. And among those which are available I do not see any combination of them which might be used to compute the Market Cap indirectly.
For those users of Thinkorswim who find this an essential item to access through a custom script you will need to submit this as a feature request to TD Ameritrade support.
There is one way to accomplish what you described using the RTD functionality of MS Excel. The following video explains how to connect an Excel spreadsheet to the live data stream of Thinkorswim. (however this only works on Windows version of Thinkorswim).