NetSuite SuiteQL built-in functions

I wrote an article before introducing SutieQL Query Tool, and today I will continue to explore the value of SuiteQL.

NetSuite SuiteQL Query Tool_Is netsuite easy to use_Mao Yanzhe's Blog-CSDN Blog This is a very good NetSuite data query tool, free and powerful! So I can't help giving Amway to everyone. First, let me introduce the background. SuiteQL is a basic component that comes with SuiteAnalytics, providing NetSuite developers with a tool for data query according to SQL syntax. But SuiteQL only has an API for developers to use, and there is no UI tool available for end users. Where there are pits, there are pit-fillers. Therefore, a user developed a Bundle based on the SuiteQL component and endowed it with a UI for easy use by end users. Alright, enough gossip, let's serve hard dishes! https://blog.csdn.net/remottshanghai/article/details/127032699 There are several built-in functions (Built-In) in SuiteQL, which can help us to write SQL statements more conveniently. For a detailed introduction, please refer to the online help.

NetSuite Applications Suite - SuiteQL Supported Built-in Functions https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/article_161950565221.html Now we use a SQL statement to comprehensively practice:

SELECT
	Transaction.TranID,
	Transaction.trandate,
	Transaction.postingPeriod,
	TransactionAccountingLine.Account,
	BUILTIN.DF( TransactionAccountingLine.Account ) AS func_df,
	TransactionAccountingLine.Debit,
	TransactionAccountingLine.Credit,
  	BUILTIN.CONSOLIDATE(TransactionAccountingLine.Credit, 'INCOME', 'DEFAULT', 'DEFAULT', 3, 263, 'DEFAULT') as func_consolidate,
	BUILTIN.CURRENCY(TransactionAccountingLine.Credit) as func_currency,
	BUILTIN.CURRENCY_CONVERT(TransactionAccountingLine.Credit, 1) as func_currency_convert,
	BUILTIN.DF( TransactionLine.Subsidiary ) AS Subsidiary,
	BUILTIN.HIERARCHY(TransactionLine.Subsidiary, 'DISPLAY_JOINED')	 AS func_hierarchy
FROM 
	Transaction
	INNER JOIN TransactionAccountingLine ON
		( TransactionAccountingLine.Transaction = Transaction.ID )
	LEFT OUTER JOIN TransactionLine ON
		( TransactionLine.Transaction = TransactionAccountingLine.Transaction )
		AND ( TransactionLine.LineSequenceNumber = TransactionAccountingLine.TransactionLine )
WHERE 
	--Transaction.trandate >= BUILTIN.RELATIVE_RANGES('TY', 'START')
	Transaction.postingPeriod  in BUILTIN.PERIOD('LFY', 'START', 'ALL', '>')  
	AND ( TransactionAccountingLine.Account IS NOT NULL )
ORDER BY
	Transaction.trandate

In this statement, we involved the following functions:

  • BUILTIN.DF( TransactionAccountingLine.Account )
  • BUILTIN.CONSOLIDATE(TransactionAccountingLine.Credit, 'INCOME', 'DEFAULT', 'DEFAULT', 3, 263, 'DEFAULT')
  • BUILTIN.CURRENCY(TransactionAccountingLine.Credit) 
  • BUILTIN.CURRENCY_CONVERT(TransactionAccountingLine.Credit, 1)
  • BUILTIN.HIERARCHY(TransactionLine.Subsidiary, 'DISPLAY_JOINED')
  • BUILTIN.RELATIVE_RANGES('TY', 'START')
  • BUILTIN.PERIOD('LFY', 'START', 'ALL', '>')  

The result of the operation is as follows:

Due to a severe lack of supporting material, there are also two functions that are not clear how to use.

  • CF
  • NAMED_GROUP

If you have a clear understanding of the students, please share with the thread, thank you!

postscript

After raising the Support Case, I got the following reply:

For BUILTIN.CF,  This function has only one parameter - UMD field where UMD means Unified Metadata. Intention of this function is to get CRITERIA version of field value. In some special cases, there is different SQL fragment defined for UMD field whether it is used as return value or criteria field. (e.g. UMD field which is used as simple join key on UMD level, but it is implemented by two or more keys in DB - composite key). This function will allow us to return criteria version as return value in case that we would like to filter data outside of DB (e.g. in JAVA code or on customer side).

Examples of SuiteQL queries for BUILTIN.CF:
    1. select transaction.status, BUILTIN.CF(transaction.status) from transaction

    2. /* does not return anything because "where transaction.status" and "select transaction.status" are different SQL expressions */
         select * from transaction where transaction.status IN (select transaction.status from transaction)

    3. /* returns everything because "where transaction.status" and "select BUILTIN.CF(transaction.status)" are same SQL expressions */
         select * from transaction where transaction.status IN (select BUILTIN.CF(transaction.status) from transaction)

For BUILTIN.NAMED_GROUP, we know only following:
parameters are: Builtin.Named_Group(record_name, group_name) where record_name is UMD name of record and group_name is name of group defined on that record. On each record there can be different set of group_names - so the question should be directed to owner of the specified record.

The function returns filter options for workgroups for some record types (filter by: My Location, My Subsidiary, My team, etc). Named groups (label: my) currently for records: 
    • Department
    • Class
    • Location
    • Subsidiary
    • Entity

Also, every key field targeting above records (such as Entity -> Location) should support filtering by the {Me} group.

Example of SuiteQL queries for BUILTIN.NAMED_GROUP:
    1. SELECT id FROM Transaction WHERE entity IN (BUILTIN.NAMED_GROUP('employee', 'me'))
    2. SELECT id FROM Transaction WHERE entity IN (BUILTIN.NAMED_GROUP('employee', 'me'), BUILTIN.NAMED_GROUP('employee', 'me'), 5, 6, 7, 8)

If you have any questions about NetSuite, welcome to talk. My email: [email protected]

Guess you like

Origin blog.csdn.net/remottshanghai/article/details/130672644