I don't know about SuiteQL, but you can pull it into a Saved Search, at least for transactions. Custom Form is a selectable field; if you can't get the form ID by selecting that with whatever tool you're using, I just verified a Formula (Numeric) field of {customform.id} works.