I need to determine if a record is an entity, a cu...
# suitescript
a
I need to determine if a record is an entity, a custom record or a transaction... without loading the record... I have the record type and id. so far I've got custom records if the record.Type startswith
"custom"
I was loading the record and checking for an
entityid
but I have this new requirement that I can't load the record. I was never really happy with that solution anyway, so wondering if there's better way
c
When you say you have the record type, how does that differ from what you're trying to determine?
a
I don't have a list of all the transaction types and/or entity types
c
Are you needing to map the type you have to one of those 3 categories?
👍 1
Ah got it
Since internal IDs are shared across all entities and all transactions, you could consider querying those tables to compare to the record id you're given
For example, if I'm given a type and an ID, I can run this query
SELECT id, recordtype FROM transaction WHERE id = ${id}
and compare the results to what I have
Maaaaybe even like
SELECT COUNT(id) FROM transaction WHERE id = ${id} AND recordtype = ${type}
same for entity
a
neat, that seems pretty solid, thank you
🌟 1
c
Let me know how it goes!
Depending on the kind of script you're running, you could always build a map using
SELECT DISTINCT recordtype FROM transaction
to get a list of record types for transactions in your environment
hmm,
recordtype
isn't on the entity table
a
Works great thanks again... this is also to hopefully explain "why the hell do you even want this???" 🙂
🎉 1
render.mergeEmail
has 3 different attributes depending on broad record type
👍 1