Thursday, June 1, 2023

delete from using query run class in D365FO

/// <summary>
/// Method that deletes records in any given table based on the value.
/// </summary>
/// <param name = "_tableToClean">
/// The ID of the table in which records are deleted.
/// </param>
/// <returns>
/// The number of records deleted from the table.
/// </returns>
protected NumberOfRecords cleanUpTableRecords(TableId   _tableToClean)
{
	Query                   query;
	QueryBuildDataSource    queryBuildDataSource;
	QueryBuildRange         queryBuildRange;

	query = new Query();
	queryBuildDataSource = SysQuery::findOrCreateDataSource(query, _tableToClean);

	return int642int(Query::delete_from(query, true, true, true));
}

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8