SysQuery::findOrCreateDataSourceByName Method [AX 2012]
Finds or creates a QueryBuildDataSource object from the specified String.
Syntax
client server public static QueryBuildDataSource findOrCreateDataSourceByName(
Query query,
str queryBuildDataSourceName,
TableId tableId,
[str parentQueryBuildDataSourceName,
TableId parentTableId,
boolean emptyFieldList])
Run On
Called
Parameters
- query
Type: Query Class
The query in which to find or create the QueryBuildDataSource object.
- queryBuildDataSourceName
Type: str
A String that represents the name of the QueryBuildDataSource object to find or create.
- tableId
Type: TableId Extended Data Type
The ID of the table for the QueryBuildDataSource object; this parameter is used to make sure that the correct type of QueryBuildDataSource object is found.
- parentQueryBuildDataSourceName
Type: str
The name of the parent QueryBuildDataSource under which to create the new QueryBuildDataSource object if it is not found.
- parentTableId
Type: TableId Extended Data Type
The ID of the table under which to create the QueryBuildDataSource object; this parameter is used to make sure that the correct type of parent QueryBuildDataSource object is found.
- emptyFieldList
Type: boolean
Specifies whether the data source should have an empty field list when it is created; this parameter does not modify an existing data source when one was found.
Return Value
Type: QueryBuildDataSource Class
The found or newly created QueryBuildDataSource.
Remarks
This API will search for the QueryBuildDataSource objects by name. If an object is found, the method will make sure that the QueryBuildDataSource object is of the expected table ID. When the table ID does not match, null Nothing nullptr unit a null reference (Nothing in Visual Basic) will be returned. If an object is not found, a new QueryBuildDataSource object is created by using the specified name and table ID. If the value of the parentQueryBuildDataSourceName parameter is specified, the data source will be created under that specific parent data source. If that parent data source cannot be found, the object is not created.
The value of the parentTableId parameter is also used to verify the correct parent table type.