Does anyone know a way to find the internal id of ...
# suitescript
t
Does anyone know a way to find the internal id of a record when all you have is the rectype (the integer value of the internal id)?
b
@Tyler Are you saying you have the internal id (number) of the record, but not the internal id of the record type? Have you checked the SuiteScript Record Browser? You can find all the internal ids of all record types that are exposed to SuiteScript there. In some cases such as the 'transaction' record type you could load the record and then find out what the subtype is (salesorder/cashsale/invoice/cashrefund/etc). It would help if you told a bit more about what you're trying to do.
t
Sorry, I should have been more clear. I have a custom List/Record field that sources in the record type depending on the value of another field, however when I use getValue on that field, it only returns the numeric internal id and not the actual internal id. I was hoping for some way to dynamically find an internal id with just the numeric value
h
I've done something similar that searches for internal id with text value of the list/record field. Not sure if it's something you're looking for.
Copy code
function getListScriptId (list, text) {
            let listScriptId = null;

            search.create({
                type: list,
                columns: [
                    'name',
                    'scriptid'
                ]
            }).run().each(function(result) {
                // Note: From tests, the script ID from the search results are always uppercase.
                if (result.getValue("name") === text) {
                    listScriptId = result.getValue('scriptid');
                }
                // Stop iterating when we find the target ID.
                return (listScriptId === null);
            });

            return listScriptId;
        }
n
As far as I know, you cannot get the internal ID of the actual record if you only have the Record Type.
Instead of the Record Type for your List/Record field, why can't you use the actual record as your List/Record option?