Wednesday, November 8, 2017

XQuery to save source code from all tables and classes

You can use this XQuery, with for example BaseX, to save all your source code from table and classes to an XML file:
  for $t in AxClass | AxTable  
  order by $t/local-name(.), $t/Name ascending

  for $y in ($t/SourceCode/Methods/Method)

  return <Code Type='{$t/local-name(.)}' Parent="{$t/Name/text()}" MethodName="{$y/Name/text()}" Source="{$y/Source/text()}"/>

Query range function: Less than date and not date null

There is a lessThanDate query function in AX, but it also selects blank dates.

Here is a suggestion for a similar function, that does not include the blank dates:
public static str lessThanDateAndNotNull(int relativeDays = 0)
    utcdatetime  currentDateTime;      

    currentDateTime = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), 

    return SysQuery::value(dateNull() + 1) + ' .. ' +            
           SysQuery::value(DateTimeUtil::date(DateTimeUtil::addDays(currentDateTime, relativeDays - 1)));  

Friday, November 3, 2017

XQuery to use with BaseX to find elements with no configuration key

Here is an XQuery that you can use with BaseX to find elements with no configuration key:
  for $t in AxTable | AxEnum | AxEdt | AxDataEntityView | AxMenuItemAction | AxMenuItemDisplay | AxMenuItemOutput
  order by $t/local-name(.), $t/Name ascending
  where fn:empty($t/ConfigurationKey)
  return <Element type='{$t/local-name(.)}' Name='{$t/Name/text()}' ConfigKey='{$t/ConfigurationKey}'/>

More on BaseX