Sunday, January 23, 2022

Ranges on DateAndTime Field


static void CreatedDateTimeRange(Args _args)
{
    Query                   query;
    QueryRun                queryRun;
    QueryBuildDataSource    qbds;
    QueryBuildRange         qbr;
    CustTable               custTable;
utcDateTime             userDateTime;

hours = 8;
    

userDateTime = DateTimeUtil::addHours(DateTimeUtil::getSystemDateTime(),hours);
 
    // Instance the class Query
    query =  new Query();
 
    // Add DataSource to Query
    qbds = query.addDataSource( tableNum(CustTable));
 
    // Add a range
    qbr = qbds.addRange( fieldNum(CustTable,CreatedDateTime));
 
    // Set range value
    qbr.value(SysQuery::range( "01/01/2012","30/12/2012" ));

or

qbr.value(SysQuery::range(userDateTime , DateTimeUtil::getSystemDateTime()));
 
    // Run Query
    queryRun = new QueryRun(query);
 
    // Retrieves the next record from the query.
    while(queryRun.next())
    {
        // Get Result
        custTable = queryRun.get( tableNum(CustTable));
 
        // Show AccountNum
        info(custTable.AccountNum);
    }
}

Insert table data from one DB to another DB SQL script

 


 Insert table data from one DB to another DB SQL script


SQL 1:

INSERT INTO <Target DB>.dbo.<Table Name>

SELECT *

FROM <Source DB>.dbo.<Table Name>

where <Source DB>.dbo.<Table Name>.<Table field name>= '<values>'

 

SQL 2:

INSERT INTO [target db].[dbo].[table] (<columnA>,<columnB>,…)

SELECT <columnA>,<columnB>,…

FROM [source db].[dbo].[table] 

Table browser in D365FO

D365URL/?mi=SysTableBrowser&tableName=TableName&cmp=LegalEntity

Sample Dialog Syntax - 1

 class AffiliationAutoAssignment extends RunBaseBatch {     // 1. Class Declaration and Pack variables     #define.CurrentVersion(1)     #de...