AL, C/AL, Development Tips, Extension Package, Information, Modern Development Tool, NAV 2016, NAV 2017, NAV 2018, PowerShell, Tip & Tricks, upgrade, V1, V2, Visual Studio Code

Future of Navision is extensions V2?

With the release of Dynamics 365 Business Central a successor of Dynamics NAV, things are going to change. If I am not wrong from year 2020 Modern Development Environment will be the only platform available to developers.

In every NAV upgrades biggest challenge was customizations, since objects are fully accessible to developers, so we customize the solution as we want as a developer spreading unstructured, difficult to maintain, customized code everywhere and in all objects.

The beauty of product is, it is totally customizable and adaptable to customer’s business. Customizing Navision is easy and quick to deploy. C/AL is easy to learn and code.

Due to these heavy customizations and unstructured codes upgrade to new version of the product required long time and efforts. Hard to merge, too much efforts leading to high cost, usually many customer prefer to stay with their current version, and miss new capabilities of product available in future versions of Navision.

With release of NAV 2016 concept of extension was introduced. This introduced the concept of writing code isolated from the core objects and use events to interact with the standard codes. Now create the extension that can be installed or uninstalled any time without affecting the original base layer of the product. We call it extension V1.

These were also developed using C/AL and deployed using PowerShell. But still it always felt like something is missing. Then last year Microsoft came up with release NAV 2018 which introduced second generation of extension, we call it extensions V2.

This introduced completely new development platform based on Visual Studio Code Modern Development Environment. It uses new AL language an evolution of C/AL. Now this will be the future.

Dynamics 365 Business Central platform (on-premise and SaaS) uses this development model. Probably this will be the only development platform available from year 2020.

In Business central base application is now an entire extension based with some system objects in CSIDE, In future release you may not have any more side by side development, you will only be having AL and extensions.

 

So what next?

 

  • We should now concentrate on learning VS Code and AL as in future this will be the only way to modify the application.
  • Now we need to make our self-familiar with the Web Client as Windows Client will be obsolete soon.
  • We should start moving our all customization to extensions.
  • Now we should start thinking in direction of AL type customization rather than old C/AL type coding practice.

 

What do you think?

I will come up with more details as progress in this direction. Till then keep learning and sharing with others.

 

 

 

Advertisement
Application, Area, Development Tips, Extension Package, How To, Information, Library, Machine, Multitenancy, NAV 2017, Notification, Permission, PowerShell, Readiness Library, Series, Tagging, Time, Tip & Tricks, Web Services, What's New

New Changes or features for Developer and IT Pro Changes in Microsoft Dynamics NAV 2017

Although it is too early to discuss on features and capabilities which we are going to get in our new release, we should wait for exact information post release of same.

Here are few extracts from available documents pre-release of the product.

You will find most of the features similar to which we have discussed in our earlier posts for Madeira Preview Project.

New thing is capability of extensions and Web Services are enhanced and programmatically handling Notifications.

 

Extensions

Dynamics NAV 2017 includes many new capabilities for Extensions:

  1. You can now include reports, XMLports, and queries in your extension along with new custom report templates.
  2. Default or initial data for new tables as part of your extension. These data will be included in the package file (.navx) and inserted into the table at the time of installation of the extension.
  3. You can include translated captions and constants for one or more languages by including object language files in the extension package.
  4. A translation only extension could be built that translates strings for base objects or objects for another extension.
  5. You can include and deploy .NET interop types executed on the server, client-side JavaScript or WinForms extensibility control add-ins.
  6. Extension can include a web service and configure it for the tenant the extension is being installed for in a multitenant deployment.
  7. Two new C/AL functions NAVAPP.RESTOREARCHIVEDATA and NAVAPP.DELETEARCHIVEDATA, you can easily restore or delete archived table data during a reinstall or upgrade of the extension.
  8. Use the NAVAPP.RESTOREARCHIVEDATA function to simply copy the data back from the archive table when special upgrade logic is not required.
  9. Use the NAVAPP.DELETEARCHIVEDATA function in situations where you do not want to restore the archived data for the table.
  10. You can publish an extension to a Dynamics NAV Server instance that is configured with an Azure SQL Database using new parameters added to the Publish-NAVApp cmdlet. The new parameters are used to provide the location and credentials for connecting to an existing Azure SQL database you created.
  11. Users with the appropriate permissions in the application can install and uninstall extensions from the Extensions Management page. The page will display all of the extensions that are currently published.

 

Web Services in multitenant deployments

You can publish per-tenant web services in situations where a web service has not been published for all tenants of the service.

You can also package and deploy published web services for base objects or extension objects in an extension.

The packaged web services will be published to the tenant for which the extension is being installed.

 

Notifications in the UI

Dynamics NAV 2017 introduces a programmatic way to send non-intrusive notifications to the UI in the Dynamics NAV Web client.

Notifications provide users with information about a current situation, but do not require any immediate action or block users from continuing with their current task.

In the UI, notifications appear in the Notification bar (similar to validation errors) at the top of the page on which a user is currently working.

Notifications that are defined on sub-pages, for example in parts and FactBoxes, appear in the same Notification bar.

Validation errors on the page will be shown first.

In the development environment, you create notifications in C/AL by using the newNotification and NotificationScope data types and the following functions.

  1. MESSAGE specifies the content of the notification that appears in the UI
  2. SCOPE specifies the scope in which the notification appears, which can be LocalScope or GlobalScope.
  3. A LocalScope notification appears in context of what the user is currently doing, while GlobalScope notifications are not directly related to the current task. Note: GlobalScope is currently not supported.
  4. SEND sends the notification to be displayed by the client.
  5. ADDACTION adds an action on the notification. Actions enable you to create interactive notifications that provide users with different actions that they can take to address the notification, like opening an associated page for modifying data. A notification action calls a function in a codeunit that you define, passing the notification object in the call. You then add business logic to the function for handling the action.
  6. SETDATA and GETDATA set and retrieve a data property value for the notification, which is typically needed when actions are invoked.

The following example illustrates the simplified code for local scope notification that has an action:

VAR

CreditBalanceNotification@1170000000 :Notification;

PROCEDURECreditBalanceCheck@1170000023(Customer@1170000000 : Record 18);

BEGIN

//Create the notification

CreditBalanceNotification.MESSAGE(‘Thecustomer”s current balance exceeds

their credit limit’);

CreditBalanceNotification.SCOPE :=NOTIFICATIONSCOPE::LocalScope;

//Add a data property for the customernumber

CreditBalanceNotification.SETDATA(‘CustNumber’,Customer.”No.”);

//Add an action that calls the ActionHandler codeunit, which you define  in the next step.

CreditBalanceNotification.ADDACTION(‘Gohandle this’,

CODEUNIT::NavExtensionInstallationMgmt, ‘OpenCustomer’);

//Send the notification to the client.

CreditBalanceNotification.SEND;

END;

In the “Action Handler” codeunit, you would add code to handle the action in a global function, called OpenCustomer, which has a Notification data type parameter. You could use the GETDATA function to get the value of the data sent with the notification:

PROCEDUREOpenCustomer@1170000024(theNotification@1170000000 :

Notification);

VAR

CustNo@1170000001 : Code[20];

BEGIN

// Do the code to handle the action.Optionally retrieve data carried by

the notification.

CustNo :=theNotification.GETDATA(‘CustNumber’);

// …

END;

 

Setup data in the US version

The US version of Dynamics NAV 2017 includes two RapidStart packages that will enable a fast implementation for a new company.

These data packages come with a new Windows PowerShell script to upload to server – and can be enabled for new companies.

Create a new company in the Companies page, and choose the Enable assisted setup field.

Then, use the Import-NAVConfigurationPackageFile cmdlet to import the RapidStart packages.

Then open the new company, the packages are applied, and you will be taken through an assisted setup experience.

 

Application area tagging

The Application Areas system offers developers, administrators, and users the ability to define differentiated user experiences according to application scope.

By selecting a set of application areas, users only see UI elements that are specific to the application features that they need to perform their tasks.

When companies want to create differentiated user experiences, the Application Areas system should be considered as an option not compulsory to adopt.

 

Time series library

One of the most popular topics for machine learning is forecasting based on historical data.

Many algorithms are there that can do this, but you do not have to know them, because MS have wrapped them for us.

Five of these algorithms, are wrapped in one Azure ML experiment, added logic that compares different results and returns the best one accompanied by an indicator of the prediction’s quality.

There is also a generic API on top of this that allows Dynamics NAV developers create their own functionality that helps customers find the business-critical information that may be hidden in their database.

You can perform time-series analysis in the familiar development environment.

The time series library is used by the Sales and Inventory Forecast extension.

 

Source:- https://mbs.microsoft.com/Files/partner/NAV/Readiness_Training/ReadinessTrainingNews/WhatsNewDynamicsNAV2017LimitedBeta.pdf

I will come up with more details in my upcoming posts.

 

 

Backup, Development Tips, How To, Information, PowerShell, Schedule, Server, SQL, Tip & Tricks

SQL Server Database Backup using PowerShell

In this post we will see how we can take backup of databases from SQL Server using PowerShell and schedule it as a daily run Plan.

Step-1 : We will create Powershell Script to take backup of Databases in SQL Server.

SCheduleJob-18

Here is the full Script for your ready refrence.

param( $serverName, $backupDirectory )

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.SMO”) | Out-Null

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.SmoExtended”) | Out-Null

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.ConnectionInfo”) | Out-Null

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.SmoEnum”) | Out-Null

$server = New-Object (“Microsoft.SqlServer.Management.Smo.Server”) $serverName

$dbs = $server.Databases

foreach ($database in $dbs | where { $_.IsSystemObject -eq $False })

{

$dbName = $database.Name

$timestamp = Get-Date -format yyyy-MM-dd-HHmmss

$targetPath = $backupDirectory + “\” + $dbName + “_” + $timestamp + “.bak”

$smoBackup = New-Object (“Microsoft.SqlServer.Management.Smo.Backup”)

$smoBackup.Action = “Database”

$smoBackup.BackupSetDescription = “Full Backup of “ + $dbName

$smoBackup.BackupSetName = $dbName + ” Backup”

$smoBackup.Database = $dbName

$smoBackup.MediaDescription = “Disk”

$smoBackup.Devices.AddDevice($targetPath, “File”)

$smoBackup.SqlBackup($server)

“backed up $dbName ($serverName) to $targetPath

}

Save this Script file as ps1 extension.

You can create the script using even notepad.

 

Step 2: We will Create Batch file to call PowerShell scrip and to be used in Windows scheduler.

SCheduleJob-18

Save as .BAT file. Here is the batch script for ready refrence:

powershell -ExecutionPolicy RemoteSigned

-File “C:\User Data\SQL Backup\Tools\SQLServerBackupAllDatabase.ps1”

-serverName “INDEL-AXT5283NB”

-backupDirectory “C:\User Data\SQL Backup”

>> “C:\User Data\SQL Backup\LOG\\%date%.log”

Step 3 : Create a Windows Scheduler

Open Windows Task Scheduler.

Create New Task as shown below :

SCheduleJob-18

Enter Name & Description on General Tab as shown below:

SCheduleJob-18

On Trigger Tab create New Trigger and enter details as shown below :
SCheduleJob-18

On Action Tab Create Action and enter information as shown below : Here Select the batch file created in Step 2.

SCheduleJob-18

In Settings Tab do the setting as shown Below :

SCheduleJob-18

Click on OK to Save the Task and return to Task Scheduler Window.

Here you can see the newly created Task.

SCheduleJob-18

When Task is executed you will find the backup of databases at defined path in the script.

SCheduleJob-26

You can also find Log file at the path defined in batch.

SCheduleJob-27

Thats all for this post, will come up will more information in my up comming posts.

Development Tips, How To, Information, PowerShell, Tip & Tricks

More about Loops in PowerShell

Do Until

The logic of this loop is to execute the Do {block} until (the condition is true).

As usual in PowerShell, pay close attention to the style of brackets, the curly brackets or parentheses guides you to write the correct code.

PS-L-1

Note: Don’t try: Until ($strQuit = “N”).  You need here to use -eq, this is PowerShell’s way of comparing two values.

Do While

The logic of ‘Do … While’ is the opposite of the Do Until. {Execute the block statement} while the (condition is true)
PS-L-1

Note: There are difference between until & while in above two examples: Until ($strQuit -eq “N”) While ($strQuit -ne “N”)

 

‘While’ on Its Own – No Explicit ‘Do’

This method is the more traditional way with the (condition) followed by the {Block command}.  Clearly, PowerShell’s While loop is simpler and more basic than the ‘Do … While’ construction in above two examples.

PS-L-1

Note: In this example the ‘While’ clause is at the beginning instead of the end.

 

‘For’ Loop

Below example is a simple method using the keyword ‘For’. As usual there is a (condition) and {Block Statement}.

The speciality of this loop is the <init> and <repeat> sections.

Here is the syntax:

For (<init>; <condition>; <repeat>) {<command_block>}

Example: Times Table for 25

PS-L-1

One side-effect of the For loop is that it always returns the <init> before it tests for the condition.

The <repeat> modifies the $i variable, which is then tested inside the <condition> of the next cycle.

 

‘Foreach’ loop

The PowerShell ‘Foreach’ loop is more complex, and has more arguments than the ‘for’ and ‘Do While’ loops.  The key feature is that the loop interrogates an array, known as a collection.  It then applies a {Statement Block} to each iteration.  In addition to the position and the type of bracket, observe the tiny, but crucial keyword – ‘In’.

 

PS-L-1

 

PS-L-1

# PowerShell ForEach loop to display files in C:\Program files

$Path = “C:\Program Files\” “{0,10} {1,-24} {2,-2}” -f ` ” Size”, “Last Accessed”, “File Name ” Foreach ($file in Get-Childitem $Path -recurse -force) {If ($file.extension -eq “.txt”)     {     “{0,10} {1,-24} {2,-2}” -f `     $file.length, $file.LastAccessTime, $file.fullname     } }

 

# PowerShell ForEach-Objcet piping into block statement

Clear-Host $Path = “C:\Program Files\” Get-Childitem $Path -recurse -force | Foreach-Object {If ($_.extension -eq “.txt”) {Write-Host $_.fullname        } }

 

PS-L-1

 

PS-L-1

 

I will come up with more stuffs in my upcoming posts.

Till then keep practicing and stay tuned for more details.

Development Tips, How To, Information, PowerShell, Tip & Tricks

An Introduction to PowerShell – Profile

PowerShell is a great way to automate almost anything in Windows.

However, it’s not just a scripting language.

If you find yourself using it as a command line shell it may be useful to store your functions and customizations in a profile that gets loaded every time you load the Console.

The first thing we do here is check if we already have a profile. There is an automatic variable, $Profile, that stores the fully qualified location of the PowerShell profile. An easy way to check if any profile exists is to use the Test-Path cmdlet on the $Profile variable.

Test-Path $Profile

PS-18

As you can see no profile file yet created for me, so we will create one, we can easily do that with the New-Item cmdlet.

New-Item –Path $Profile –Type File –Force

Using the force parameter will cause a profile to be created even if already we have one. This means our old profile will be overwritten and new will be created.

PS-19

Profile can be edit using notepad, which can be easily started using PowerShell.

notepad $Profile

PS-20

You can put any commands, functions, alias’s and even module imports into your PowerShell profile.

I normally work on PowerShell for Navision so I would prefer loading module whenever I launch the PowerShell command, so I include my cmdlets for loading the same in my profile.

PS-21

Save the Profile and close the PowerShell. Next time I launch PowerShell this Module get loaded for me by default.

Finally, I would like to also have some customizations to the console. One is it basically determines if you have opened an elevated PowerShell console and changes the font colour, this way I will always remember that I am running with elevated privileges.

Let us Save the Profile and check the effect of this Profile.

PS-22

That’s all for today.

I will come up with more stuffs in my upcoming posts.

Till then keep practicing and stay tuned for more details.

 

Development Tips, How To, Information, PowerShell, Tip & Tricks

An Introduction to PowerShell – Execution Policies

PowerShell has something called Execution Policies, which stop you from just running any old script. In fact, by default, you can’t run any scripts and need to change your execution policy if you want to be allowed to run them. There are 4 notable Execution Policies:

  • Restricted: This is the default configuration in PowerShell. This setting means that no script can run, regardless of its signature. The only thing that can be run in PowerShell with this setting is an individual command.
  • AllSigned: This setting does allow scripts to run in PowerShell. The script must have an associated digital signature from a trusted publisher. There will be a prompt before you run the scripts from trusted publishers.
  • RemoteSigned: This setting allows scripts to be run, but requires that the script and configuration files that are downloaded from the Internet have an associated digital signature from a trusted publisher. Scripts run from the local computer don’t need to be signed. There are no prompts before running the script.
  • Unrestricted: This allows unsigned scripts to run, including all scripts and configuration files downloaded from the Internet. This will include files from Outlook and Messenger. The risk here is running scripts without any signature or security. It is recommenced that you never us this setting.

To see what your current Execution Policy is set to, open a PowerShell Console and type:

Get-ExecutionPolicy

PS-14

Set-ExecutionPolicy RemoteSigned

PS-15

To run this command you need to run the PowerShell with Administrative rights. Right click on icon and select Run as Administrator and try the command again.

PS-16

When i run PowerShell as Administrator, now i am able to execute the command successfully as in below screen.

PS-17

The proper term for a PowerShell command is a cmdlet, and from now on we will use this correct terminology. It just felt more appropriate to call them commands for this introduction.

I will come up with more stuffs in my upcoming posts.

Till then keep practicing and stay tuned for more details.

 

 

 

 

 

Development Tips, How To, Information, PowerShell, Tip & Tricks

An Introduction to PowerShell – ForEach

ForEach simply looks at a set of list and pulls out one at a time to look at them and then, perform some type of action or set of commands on it.

One different part of a ForEach loop is the keyword in that lives within that parenthetical statement. That tells PowerShell to create a single variable to hold the values that come out, one at a time, for your list.

Let’s define a variable with list of Fruits

$names = “Apple”,”Banana”,”Grape”,”Orange”,”Chiku”

When we make a list within a variable, we have created an array, which is simply a sort of matrix thing that PowerShell holds in memory that lets it store a lots of things at one time.

Let’s also initialize a count variable so we get a feel of how the loop is going.

$count = 0

Let’s use a ForEach loop to count how many names we have. Remember our keyword in we have to create a new variable that we can call FruitName. This holds each single name that comes out of that list of names we have stored in the variable $names.

ForEach ($FruitName in $names)

{

$count += 1

Write-Host “$FruitName”

}

 

Finally, I’ll add a simple Write-Host line after the end (after the right curly brace, that is) to display the count, so we can actually give us the count of names in the list of Fruits.

Write-Host “The total number of names is $count.”

 

Here is the output of above script.

PS-13

I will come up with more stuffs in my upcoming posts.

Till then keep practicing and stay tuned for more details.

Development Tips, How To, Information, PowerShell, Tip & Tricks

An Introduction to PowerShell – Do While

Do While is the simplest of the looping constructs in PowerShell.

A looping construct is basically a piece of code that repeats the same action over and over again to a set of iteration, it loops through a set of statements, doing some action in each of its iteration, until some condition is met or that set of statement is exhausted.

Do While is simply a construct that says to PowerShell, “repeat set of things until some condition becomes true”.

For example, let’s set up a control variable called count and give it an initial value of one.

$count = 1

Then, let’s set up a simple Do While construct that adds 1 to whatever value of count is already in that variable, until the variable has the number 10 in it.

Do

{

$count = $count + 1

Write-Host “The current value of the variable is $count”

} While ($count –lt 10)

 

PS-10

Another way of doing same is:

You can also set up a Do While construct so that your set of commands only executes when the condition is true. You just need to eliminate the do statement, and only use while.

While ($count –lt 10)

{

$count = $count + 1

Write-Host “The current value of the variable is $count”

}

PS-11

Only difference in above both way of using Do While construct is in first way if we initialize Count with 11 then also the loop with execute once as the condition is tested after loop is executed at least once if condition is satisfied the loop will continue else will exit. Where as in second way the condition is tested before it enters the loop and will exit before first iteration of the loop.

PS-12

I will come up with more stuffs in my upcoming posts. 

Till then keep practicing and stay tuned for more details.

 

 

Development Tips, How To, Information, PowerShell, Tip & Tricks

An Introduction to PowerShell – If/Then

The simplest form of decision making in PowerShell is the if/then mechanism.

The code that runs if your comparison clause is YES/TRUE or NO/FALSE must be surrounded within curly braces, it is best practice to put these curly braces on lines by themselves so that you can match them up when you are writing more complicated scripts.

If condition is met then

{

Do This

}

Else

{

Do This

}

Example:

If (20 –gt 15)

{

Write-Host “20 is Greater than 15”

}

 

PS-7

Here the –gt is the PowerShell switch for “greater than”.

 

Another Example using Nesting

If (20 –gt 25)

{

Write-Host “20 is Greater than 25”

}

elseif (25 –gt 20)

{

Write-Host “25 is Greater than 20”

}

PS-8

You can include n number of these elseif blocks in your script, there is no maximum limit for how many times it occurs in script.

If (10 –gt 11)

{

Write-Host “10 is Greater than 11”

}

elseif (11 –lt 10)

{

Write-Host “11 is Less than 10”

}

elseif (20 –gt 40)

{

Write-Host “20 is Greater than 40”

}

else

{

Write-Host “None of above conditions are true”

}

PS-9

I will come up with more stuffs in my upcoming posts.

Till then keep practicing and stay tuned for more details.

How To, Information, PowerShell, Tip & Tricks

An Introduction to PowerShell – basics and how to define Variables

PowerShell is built into Windows, so there is no requirement of separate fee or licensing cost. In addition, different server products come with their own Power Shells, too, which expands the capability to do things you want using PowerShell.

For demo purpose I am using Windows PowerShell ISE.

PS-1

An introduction to scripts

Scripts in PowerShell are basically just text files with the special filename extension of ps1.

To create a script, you enter a series of PowerShell commands in a sequence in a new Notepad file or any text editor you like, and then save that file with extension as .ps1, where name of your file is a friendly description of your script with no spaces.

 

PS-2

How do I run my scripts?

To run a PowerShell script that you already have, you enter in a PowerShell window either:

The full path (folder and file name) of the script, like so: c:\powershell\myscript.ps1

Or

If your script is in the current directory the console is looking at, use a period and then a backslash, like this: .\myscrip.ps1

Other than this, there is nothing special needed for creating a script in PowerShell. You can simply add the commands you like.

 

PS-3

How do I define Variables?

In PowerShell, variables always have a dollar sign ($) prefixed before them.

Let us declare few variables right now:

$name = ‘Ashwini’

$anynumber = 111074

$location = ‘Ghaziabad’

$listofnumbers = 15,20,35,40

 

PS-4

If I want to define a variable with text as its value, I will require to add a single quote on either side of the text value.

Let’s say we want to find out the total number of cmdlets available on the system, we can use:

(get-command).count

 

PS-5

Let’s declare a variable to store that count in. We’ll call it

$numbersofcmdlets

We will store output in this variable of the (get-command).count .

$numbersofcmdlets = (get-command).count

Now we can use this variable as part of something else.

For a simple example, let’s look at the Write-Host cmdlet, which simply writes text to the screen of the machine hosting the PowerShell session. Write-Host has a lots of capabilities, but in its simplest form, you can just say:

Write-Host “Dynamics Nav Blog Site by Ashwini Tripathi”

You can integrate variables with Write-Host. You just call them with the dollar sign notation and work them right into your text.

For example, I can say:

Write-Host “There are $numbersofcmdlets commands available for use on this system.”

 

PS-6

I will come up with more stuffs in my upcoming posts. 

Till then keep practicing and stay tuned for more details.