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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 20.02.2018, 16:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,626 / 848 (80) +++++++
Регистрация: 28.10.2006
alexef: Sample Extension v2.0 — Dynamics NAV / AL extension / SaaS — ALF Export Setup Tabs to Excel
Источник: https://blogs.technet.microsoft.com/...tabs-to-excel/
==============

In this blog post I will try to show an example of creating an extension v2.0 (AL extension).
This is will be the extension for Dynamics 365 for Finance and Operations, Business edition system (Cloud NAV), in other words: the app for SaaS environment.
A good start point for an extension story: Getting Started with AL
For the questions and searches you could use GitHub page: https://github.com/Microsoft/AL/issues
In my scenario I firstly create an object via classic way (Object Designer, on-prem version) and after that convert this object to AL object with use The Txt2Al Conversion Tool.

GitHub project: https://github.com/finn777/ALF-Expor...-Tabs-to-Excel

Before start I have in my hands ---
- NAV 2018 (W1) CU 02, build 20348 system:

- Cloud sandbox (microsoft-sandbox):
Remember that you not one in this sandbox. // In general, you could see that Users page shows more than one line.
BUT if you need you always can do Reset Sandbox and start from a clean environment.







-Visual Studio Code with AL Language extension: // ‘Visual Studio Code’ is not ‘Visual Studio’



Well, what my extension going to do.
I’ll try to create a ‘processing only’ report that export a few Setup tables to the Excel.
An analog of how to do it via Configuration Packages:



We are trying to create Excel file via one click and add some improvements: all data on the one sheet, add some additional info and etc..

For the Excel export purpose I am going to use the functions from Table Excel Buffer (370).
I use report with no data item and with ProcessingOnly=Yes; UseRequestPage=No
Why I use a report? Because you could add Pages and Reports to Search in Cloud system. // Adding Pages and Reports to Search
During building an object that are going to be run under Cloud (SaaS) remember that not all functions / objects could be used in extension v2.0 (AL extension).
You should use function that has Property FunctionVisibility = External // Question: FunctionVisibility
Most virtual/system tables are currently not allowed for usage in AL extension. // Remember Modern DEV (AL) story is very fresh and change / improvement every month
I like this sentence from the on-line help (Testing your Extension):
Always test in a true Dynamics 365 for Finance and Operations, Business edition SaaS environment. If you test in on-prem, you might miss errors that would be seen on SaaS.

My object ALF Export Setup Tabs to Excel (Original_on-prem).txt:
===

OBJECT Report 50126 ALF Export Setup Tabs to Excel { OBJECT-PROPERTIES { Date=20.02.18; Time=[ 9:50:13]; Modified=Yes; Version List=1.0; } PROPERTIES { ProcessingOnly=Yes; OnPreReport=BEGIN TempExcelBuffer.DELETEALL; RowNo := 1; ColNo := 1; EnterCell(RowNo,ColNo,FORMAT(COMPANYPROPERTY.URLNAME+';'+TENANTID+';'+USERID+';'+FORMAT(TIME)),TempExcelBuffer."Cell Type"::Text,TRUE,FALSE,TRUE); StartRowNo := 3; END; OnPostReport=BEGIN GlobalRecRef.OPEN(DATABASE::"General Ledger Setup"); GlobalRecRef.FINDFIRST; FillHeader(StartRowNo,GlobalRecRef); StartRowNo := FillLine(StartRowNo,GlobalRecRef) + 2; GlobalRecRef.CLOSE; GlobalRecRef.OPEN(DATABASE::"Sales & Receivables Setup"); GlobalRecRef.FINDFIRST; FillHeader(StartRowNo,GlobalRecRef); StartRowNo := FillLine(StartRowNo,GlobalRecRef) + 2; GlobalRecRef.CLOSE; GlobalRecRef.OPEN(DATABASE::"Purchases & Payables Setup"); GlobalRecRef.FINDFIRST; FillHeader(StartRowNo,GlobalRecRef); StartRowNo := FillLine(StartRowNo,GlobalRecRef) + 2; GlobalRecRef.CLOSE; GlobalRecRef.OPEN(DATABASE::"Inventory Setup"); GlobalRecRef.FINDFIRST; FillHeader(StartRowNo,GlobalRecRef); StartRowNo := FillLine(StartRowNo,GlobalRecRef) + 2; GlobalRecRef.CLOSE; TempExcelBuffer.CreateNewBook(SheetName); TempExcelBuffer.WriteSheet(SheetName,'',''); TempExcelBuffer.CloseBook; TempExcelBuffer.OpenExcel; TempExcelBuffer.GiveUserControl; // please comment this line for Cloud app END; UseRequestPage=No; } DATASET { } REQUESTPAGE { PROPERTIES { } CONTROLS { } } LABELS { } CODE { VAR TempExcelBuffer@1000 : TEMPORARY Record 370; RowNo@1001 : Integer; ColNo@1002 : Integer; GlobalRecRef@1003 : RecordRef; StartRowNo@1004 : Integer; SheetName@1005 : TextConst 'ENU="ENU=ALF Export Setup Tabs to Excel"'; LOCAL PROCEDURE EnterCell@1(RowNo@1000 : Integer;ColumnNo@1001 : Integer;CellValue@1002 : Text[250];CellType@1003 : 'Number,Text,Date,Time';Bold@1004 : Boolean;Italic@1005 : Boolean;Underline@1006 : Boolean); BEGIN TempExcelBuffer.INIT; TempExcelBuffer.VALIDATE("Row No.",RowNo); TempExcelBuffer.VALIDATE("Column No.",ColumnNo); TempExcelBuffer."Cell Value as Text" := CellValue; TempExcelBuffer."Cell Type" := CellType; TempExcelBuffer.Bold := Bold; TempExcelBuffer.Italic := Italic; TempExcelBuffer.Underline := Underline; TempExcelBuffer.INSERT; END; LOCAL PROCEDURE FillHeader@4(StartRowNo@1001 : Integer;LocalRecRef@1002 : RecordRef); VAR LocalFieldRef@1000 : FieldRef; BEGIN RowNo := StartRowNo; ColNo := 1; EnterCell(RowNo,ColNo,LocalRecRef.CAPTION + ' ('+FORMAT(LocalRecRef.NUMBER)+')',TempExcelBuffer."Cell Type"::Text,TRUE,TRUE,TRUE); ColNo := 2; EnterCell(RowNo,ColNo,'VALUE',TempExcelBuffer."Cell Type"::Text,TRUE,TRUE,TRUE); ColNo := 3; EnterCell(RowNo,ColNo,'CLASS',TempExcelBuffer."Cell Type"::Text,TRUE,TRUE,TRUE); ColNo := 4; EnterCell(RowNo,ColNo,'OPTION',TempExcelBuffer."Cell Type"::Text,TRUE,TRUE,TRUE); ColNo := 1; FOR RowNo := (1 + StartRowNo) TO (LocalRecRef.FIELDCOUNT + StartRowNo) DO BEGIN LocalFieldRef := LocalRecRef.FIELDINDEX(RowNo - StartRowNo); EnterCell(RowNo,ColNo,LocalFieldRef.CAPTION + ' ('+FORMAT(LocalFieldRef.NUMBER)+')',TempExcelBuffer."Cell Type"::Text,TRUE,FALSE,FALSE); END; END; LOCAL PROCEDURE FillLine@6(StartRowNo@1001 : Integer;LocalRecRef@1002 : RecordRef) : Integer; VAR LocalFieldRef@1000 : FieldRef; BEGIN FOR RowNo := (1 + StartRowNo) TO (LocalRecRef.FIELDCOUNT + StartRowNo) DO BEGIN LocalFieldRef := LocalRecRef.FIELDINDEX(RowNo - StartRowNo); ColNo := 2; EnterCell(RowNo,ColNo,FORMAT(LocalFieldRef.VALUE),TempExcelBuffer."Cell Type"::Text,FALSE,FALSE,FALSE); ColNo := 3; EnterCell(RowNo,ColNo,FORMAT(LocalFieldRef.CLASS),TempExcelBuffer."Cell Type"::Text,FALSE,FALSE,FALSE); ColNo := 4; EnterCell(RowNo,ColNo,FORMAT(LocalFieldRef.OPTIONCAPTION),TempExcelBuffer."Cell Type"::Text,FALSE,FALSE,FALSE); END; EXIT(RowNo); END; BEGIN { //Please add these properties for Cloud app //Caption = 'ALF Export Setup Tabs to Excel'; //UsageCategory = ReportsAndAnalysis; //ApplicationArea = All,Basic,Suite; } END. } RDLDATA { } } ===

You could run it in on-prem version:

Now let’s use The Txt2Al Conversion Tool



cd C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client finsql.exe Command=ExportToNewSyntax, File="C:\Users\alexef\Documents\ALF Export Setup Tabs to Excel\Convert_Objects\Objects_on-prem_NewSyntax_NEW\ALF Export Setup Tabs to Excel.txt", Database="Demo Database NAV (11-0)", ServerName="RU-ALEXEF07\NAV2018", Filter=Type=report;ID=50126 txt2al.exe --source="C:\Users\alexef\Documents\ALF Export Setup Tabs to Excel\Convert_Objects\Objects_on-prem_NewSyntax_NEW" --target="C:\Users\alexef\Documents\ALF Export Setup Tabs to Excel\Convert_Objects\Objects_AL" --rename --type=Report --extensionStartId=70050126

Rename object according Best Practices for AL





Run ‘Visual Studio Code’:


AL:Go!

Set new folder for AL project: C:\Users\alexef\Documents\ALF Export Setup Tabs to Excel\AL\ALF Export Setup Tabs to Excel

Select from dropdown list: Microsoft cloud sandbox

launch.json automatically set like this:

app.json automatically set like this:

AL:Download symbols





Set “publisher” (!):



AL:Publish // F5





Okay, now close Visual Studio Code, go to our project folder, delete HelloWorld.all file and add Rep50126.ALF Export Setup Tabs to Excel.al file:

Open Visual Studio Code and comment function TempExcelBuffer.GiveUserControl:



Remember this function has FunctionVisibility = Internal // not External:

Set (uncomment) specific Cloud properties:



AL:Publish // F5

Now try to run object directly:
https://microsoft-sandbox.financials.../?report=50126



After re-login you could see that a user could search this object too:

And finally, you could see our extension in the list:



Источник: https://blogs.technet.microsoft.com/...tabs-to-excel/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
За это сообщение автора поблагодарили: Sancho (1).
Старый 01.03.2018, 16:42   #2  
finn is offline
finn
Участник
 
136 / 24 (1) +++
Регистрация: 26.12.2001
Адрес: Москва
The useful blogs with content about AL extensions:
https://demiliani.com/
http://www.kauffmann.nl/
За это сообщение автора поблагодарили: Sancho (1).
Старый 02.03.2018, 16:37   #3  
finn is offline
finn
Участник
 
136 / 24 (1) +++
Регистрация: 26.12.2001
Адрес: Москва
Additional info:

For you own Cloud sandbox you could use link:
Dynamics 365 for Finance and Operations, Business edition Sandbox tenant
https://aka.ms/getsandboxforfinancials
You should set launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "al",
"request": "launch",
"name": "cloud",
"startupObjectId": 22
}
]
}

AL: Clear credentials cache

AL: Download symbols

Sign with e-mail that has been set during creation sandbox:

Now you can run AL: Publish … and later run report in system:
Старый 05.10.2018, 23:13   #4  
Drakonian is offline
Drakonian
Участник
 
4 / 10 (1) +
Регистрация: 28.09.2018
When you create Extensions V2 for internal usage, specify target property to "Internal". So you can use all global functions, not only external
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
german_nav_developer: Buildnummern-Übersicht Microsoft Dynamics NAV 2013 Blog bot NAV: Blogs 0 15.05.2016 18:12
NAV Team: Best Practices Tips and Tricks for Upgrading to Dynamics NAV 2013 R2 or Dynamics NAV 2015 Part 2 Blog bot Dynamics CRM: Blogs 0 17.06.2015 11:00
german_nav_developer: Excel Buffer in Dynamics NAV 2013: Geschwindigkeit ist keine Hexerei Blog bot Dynamics CRM: Blogs 0 08.10.2012 14:00
Using SSRS 2008 R2 to Export Dynamics CRM Data to Microsoft Excel with Multiple Tabs Blog bot Dynamics CRM: Blogs 3 25.10.2011 17:52
german_nav_developer: Buildnummern-Übersicht Microsoft Dynamics NAV 2009 SP1 Blog bot Dynamics CRM: Blogs 0 11.06.2010 16:33

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 22:05.