End Goal: Write a function that converts a Saved S...
# suiteql
e
End Goal: Write a function that converts a Saved Search to SQL I have this working for Custom Record searches, as all the Field IDs are the same between Searches and SQL (ex. Search Field ID =
custrec_some_field_id
and its the same field ID when using SQL) Issue: Native record field ids dont always match between searches and queries (ex. An Invoice Total in a Saved Search is just
total
but in SQL, it's
foreigntotal
) Is there any sort of "mapping" between Saved Search Field IDs and Query Field IDs?
watching following 2
j
I don’t know if this will be possible without a lot of hardcoded exceptions/overrides. There are fields exposed in Saved Searches that aren’t in SuiteQL, and vice versa. Plus, Saved Searches are obviously running off some pre-joined table views (think of a transaction saved search for example, that’s a JOIN of
transaction
and
transactionline
).
e
You're right. I was under the impression that a Saved Search was just SQL "under the hood", so I figured that mapping existed somewhere (even if not publicly available) But maybe it's not SQL under the hood since (as youve pointed out), there are some fields that don't exist in SQL that are possible in Saved Searches
j
I mean….deep down it’s SQL under the hood. But not quite a one-to-one.
j
If you use SuiteAnalytics Workbook versus a saved search, my understanding is that this is pretty easy. The problem is that SuiteQL/workbooks actually use a completely different datas source than saved searches/reporting, even though most of the things are the same. "Examples of Using SuiteQL in the N/query Module" SuiteAnswers ID 91329 shows you how to convert a workbook into SuiteQL and run it.
e
@James Morris Can confirm- Workbook to SQL super simple: query.load().toSuiteQL() Now all I have to do is ask my clients to convert all of their Saved Search into Workbooks 🙂
🙃 1