AXForum  
Вернуться   AXForum > Microsoft Dynamics NAV > NAV: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 05.05.2017, 03:33   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
waldo: Convert C/AL Objects to AL with PowerShell
Источник: https://dynamicsuser.net/nav/b/waldo...ith-powershell
==============

If you are a NAV developer, you probably have heard about the upcoming “New Developer Tools”. And if you didn’t, it’s very much time for you to catch up with the readings about this, like:

And when you read this blog from Freddy – you might as well got started in Extensionsv1, and wonder how you can convert all your work to Extensionv2 – or basically – from C/AL to AL.

“The Converter”first

Well, the latest update of the NAV Developer Preview has been released (you should read all about it here), and along with that release, we got the very first version of what is going to be the “converter” – the tool that will convert exported txt-files to .al-files.

No PowerShell

I was hoping for a simple extra PowerShell CmdLet, part of the “Microsoft.Dynamics.Nav.Model.Tools” module – or any other. But no .. no PowerShell.

And while some might still think that “PowerShell” is a “step back” – well – for this tool, we actually need to take a step back. This tool has to be executed in .. uhm .. are you sitting down? .. If not .. brace yourself .. In order to use this tool .. we need to use .. the command line.



PowerShell

I actually refuse to take that step back. If you know me a little – I’ll try to make it easy on myself – and make it part of my toolset that I’m comfortable using.

And I really didn’t want to put too much time in it – so I only created a draft version – which tend to work quite well (the reason is that I do expect Microsoft to come up with a PowerShell version of this tool as well).

I remembered that back in version 2013, when we didn’t have the out-of-the-box function “Export-NAVApplicationObject”, that I created some functions in PowerShell to do just that. It was basically a wrapper around the existing command line option to export objects, using the finsql.

I decided to copy most of that business logic into a new function, and extend it with also calling the new txt2al.exe (which you can find also in the “RoleTailored Client” folder – at least in the current TENERIFE version). The end-result is a somewhat-messy-but-it-does-the-trick-function that I decided to call “Export-NAVALfromNAVApplicationObject“. You can find it on my github.

The flow

And this is basically how it works:

  1. First I need to export the objects from a certain database, identified by the serverinstance. But I can’t use the default function for that, I need something else, because Microsoft introduced a new “command” to the finsql that I need to call. While the out-of-the-box command uses the “exportobjects” command, in this case, I need the “ExportToNewSyntax”.
  2. When exported, I need to split the objects. Basically, because I might have exported multiple objects, and I need to convert all of them to individual .al files :-). But also because the txt2al.exe expects a source-folder, and not a source-file.. .
  3. As last step, I call the txt2al.exe, and convert all the files to the result-directory .. and show this directory (either in VSCode or just in a file explorer)
And here is how you can use it…

Just try for yourself .. here is an example which you can execute straight on the NAV Developer Preview VM. It installs my modules, and executes the conversion for all “wizards” in the database of the ServerInstance “NAV”, and shows the converted files in VSCode:



Find-Module | where author -eq waldo | Install-Module Export-NAVALfromNAVApplicationObject -ServerInstance NAV -WorkingFolder c:\WorkingFolder -TargetPath c:\WorkingFolder\Result -Filter 'Name=*Wizard' -OpenResultFolderInVSCode



Happy days






Источник: https://dynamicsuser.net/nav/b/waldo...ith-powershell
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
waldo: PowerShellGet & waldo’s PowerShell Modules Blog bot NAV: Blogs 0 17.01.2017 08:11
waldo: Microsoft Dynamics NAV 2017 – what’s really new? Blog bot NAV: Blogs 0 13.10.2016 05:22
waldo: Invoke-NAVSQL: Execute SQL queries on NAV databases with PowerShell Blog bot NAV: Blogs 0 08.06.2016 03:17
NAV Team: Merging Application Objects using Windows PowerShell in Microsoft Dynamics NAV 2015 Blog bot Dynamics CRM: Blogs 0 03.10.2014 14:30
NAV Team: Merging Application Objects using Windows PowerShell Blog bot Dynamics CRM: Blogs 0 07.07.2014 18:30
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 22:57.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.