Thursday, November 29, 2018

How to Start customising AL Extension for Dynamics 365 business central?

Dear Readers ,



This post is related with my AL development. Lets start to dive in Business Central to get a real idea.

Step 1. Open Visual Studio Code and Goto View-Command Pallette.

1. Select AL:GO
2. Type the project Name : Social Media
3. Change the Launch.json  file as shown in screen if you are using windows Authentication.


4. Download the Symbol from View and Command Pallete by typing AL:Download Symbol


5.Once your Symbols are downloaded you can start with real development.

6. Delete Hello World.AL file and create 1 folder with name  Tables to put all tables and create 1 file in it with name SocialMediaExtension.al as shown in screen.


How to Extend existing tables via AL Code in Visual Studio?

1. Type ttable to use code snippet. And change the file as shown in screenshot.


2. Create one more folder Page and Add one more file for SocialMediaCard.al Pages. Publish the Extension to view your ready Extension. If you need some guidance to Publish the extension you can follow my last point of blog LINK.


3. After the Publish you can check your Extension Management Page.


4. Install the Extension and check your Customer Card PAge with new fields where you can enter records for your cutomers.

I hope this blog will help to understand AL Extension and coding link with your projects.

Error while opening RTC Dynamics 365 Business Central: You do not have the following permissions on CodeUnit ApplicationManagement: Execute

Dear Readers,


This blog is a summary to resolve this step and it is fine with all RTC Clients available from NAV 2013.

Step 1.

Use this query in SQL.

Use [DATABASE]
DELETE FROM [dbo].[User];
DELETE FROM [dbo].[Access Control];
delete From [dbo].[User Property];
delete FROM [dbo].[Page Data Personalization];
Delete FROM [dbo].[User Default Style Sheet];
Delete FROM [dbo].[User Metadata];
DELETE FROM [dbo].[User Personalization];

Step 2.

Open Administration Shell of NAV version which you are using via Run as Administrator

Type these 3 Commands.

Command 1

Import-Module "${env:ProgramFiles}\Microsoft Dynamics NAV\80\Service\NavAdminTool.ps1"

Command 2


New-NavServerUser -WindowsAccount 'domain\user' -ServerInstance InstanceName
EG. New-NavServerUser -WindowsAccount "xyz\user name" -ServerInstance DynamicsNav90

Command 3

New-NavServerUserPermissionSet -WindowsAccount 'domain\user' -ServerInstance
InstanceName -PermissionSetId SUPER
EG. New-NavServerUserPermissionSet -WindowsAccount "domain\user name" -ServerInstance DynamicsNav90 -PermissionSetId COST

Step 3.

Execute the SQL Command written below you need to change Domain\User.

SET NOCOUNT ON
GO
USE [DATABASE NAME -- NAV 2013 database you want to use
GO
DECLARE @UserID varchar(100)
SET @UserID = 'domain\Username'  -- Windows Login you want to add
-- Get security identifier (SID) for specified user.  Login must be setup in SQL Server first.
DECLARE @BinarySID binary(100)
SELECT @BinarySID = sid FROM sys.syslogins WHERE name = @UserID
IF @BinarySID IS NULL
  RAISERROR('SQL Server login not found for User %s.', 10, 1, @UserID)
-- SID is stored in the User table as a formatted string.  Need to convert it.
DECLARE @StringSID varchar(238)
DECLARE @i AS int
DECLARE @j AS int
DECLARE @Grp AS int
SELECT @StringSID = 'S-'
    + CONVERT(VARCHAR, CONVERT(INT, CONVERT(VARBINARY, SUBSTRING(@BinarySID, 1, 1))))
SELECT @StringSID = @StringSID + '-'
    + CONVERT(VARCHAR, CONVERT(INT, CONVERT(VARBINARY, SUBSTRING(@BinarySID, 3, 6))))
SET @j = 9
SET @i = LEN(@BinarySID)
SET @Grp = 1
WHILE (@j < @i) AND (@Grp <= 5) BEGIN
  SET @Grp = @Grp + 1
  DECLARE @val BINARY(4)
  SELECT @val = SUBSTRING(@BinarySID, @j, 4)
  SELECT @StringSID = @StringSID + '-'
    + CONVERT(VARCHAR, CONVERT(BIGINT, CONVERT(VARBINARY, REVERSE(CONVERT(VARBINARY, @val)))))
  SET @j = @j +
END
-- Check to see if User record already exists
DECLARE @UserGUID uniqueidentifier
SELECT @UserGUID = [User Security ID]
FROM [User] WHERE [Windows Security ID] = @StringSID
IF @UserGUID IS NOT NULL
  PRINT 'User ID ' + @UserID + ' already exists in User table.'
ELSE BEGIN
  -- Generate new GUID for NAV security ID
  SET @UserGUID = NEWID()
  -- Create User record
  INSERT INTO [User]
  ([User Security ID], [User Name], [Full Name], [State], [Expiry Date], [Windows Security ID], [Change Password],[License Type],[Authentication Email],[Contact Email])
  VALUES(@UserGUID, @UserID, '', 0, '1/1/1753', @StringSID, 0, 0 ,'VE00AC832@yamaha-motor-india.com','') 
  PRINT 'Created User record for User ID ' + @UserID + '. - ' + CAST(@@ROWCOUNT AS varchar) + ' row(s) affected.'
END
-- Check to see if user is assigned to SUPER role 
IF EXISTS(SELECT * FROM [Access Control] WHERE [User Security ID] = @UserGUID AND [Role ID] = 'SUPER' AND [Company Name] = '')
  PRINT 'User ID ' + @UserID + ' is already assigned to SUPER role.'
ELSE BEGIN 
  -- Create Access Control record to add user to SUPER role
  INSERT INTO [Access Control]
  ([User Security ID], [Role ID], [Company Name],[App ID],[Scope])
  VALUES(@UserGUID, 'SUPER', '','2de23703-bbb9-4542-970d-84b6e5597f53','0')
  PRINT 'Added User ID ' + @UserID + ' to SUPER role. - ' + CAST(@@ROWCOUNT AS varchar) + ' row(s) affected.'
END
-- User Property record required to allow login
IF EXISTS(SELECT * FROM [User Property] WHERE [User Security ID] = @UserGUID)
  PRINT 'User Property record already exists for User ID ' + @UserID + '.'
ELSE BEGIN
  INSERT INTO [User Property]
  ([User Security ID], [Password], [Name Identifier], [Authentication Key], [WebServices Key], [WebServices Key Expiry Date],[Authentication Object ID])
  VALUES(@UserGUID, '', '', '', '', '1/1/1753','')
  PRINT 'Created User Property record for User ID ' + @UserID + '. - ' +  CAST(@@ROWCOUNT AS varchar) + ' row(s) affected.'
END
SET NOCOUNT OFF
GO

Wednesday, November 28, 2018

What are NotBlank, ShowMandatory, UpdatePropagation and ApplicationArea page properties in dynamics 365 business central?

NotBlank, ShowMandatory, UpdatePropagation and ApplicationArea.



NotBlank & ShowMandatory

The property “NotBlank” is used on the field level and the control level. So, you can find this property on the fields 
of a table, or on the control of a page. This indicates that this field is mandatory, and it displays an error when the 
user saves with a blank mandatory field. If you set this property on the field level, then it will always be mandatory 
on the control level as well.

The ShowMandatory only gives you a visual indication that a field is mandatory, but it doesn’t give an error if you 
leave the field blank. The indication is done with a red asterisk.
So, the ShowMandatory property is not the same as NotBlank, but can be used in combination.



UpdatePropagation


The UpdatePropagation property gives an answer to what must happen when a subpage is updated. Should the mainpage be updated as well? This property has 2 options:

Subpage: this won’t update the mainpage
Both: this will result in an update of both the subpage and the mainpage


ApplicationArea

This property is found on field, part and action controls. It is a text string that contains a comma-separated list of application area tags.

An application area tag must have the format #name, where name is the application area. It can be a combination of letters and numbers without spaces. So, to specify the Basic and Fixed Assets application areas, the property can be set to #Basic, #FixedAssets.


You can set the property to All, when the control applies to all application areas. This means that the control will always appear in the user interface. It's very important to remember that if one or more application areas are enabled in a session, any controls that are not tagged with an application area will not appear in the user interface.


How to setup these fields in AL Code inside Visual Studio?

page 50101 "Car List"
{
CaptionML=ENU='Car List',NLB='Autolijst',FRA='List de voitures';
PageType=List;
CardPageID="Car Card";
SourceTable=Car;

layout
{
area(content)
{
repeater(Group)
{
field("No."; "No.")
{
ApplicationArea=All;
}
field(Name; Name)
{
ApplicationArea=All;
}
field(Type; Type)
{
ApplicationArea=#Basic;
}
}
}
}
}


How to create Pages in AL Code Dynamics 365 Business Central from Visual Studio Code?

Dear Readers ,

There are 11 types of pages available in Dynamics 365 Business Central.


These pages we can create in Visual Studio Lets have a look in the screens. Use as much code snippets as you can.

1. Card Page





2. List Page





3. Card Part Page




4. List part Page


IMPORTANT:

To view your Page in search bar you must have to include property USAGECATEGORY.
For Reference you can check the screenshot.


SAMPLE CODE


pageextension 70000030 SocialMediaChannelPage extends "Customer Card"
{
layout
{
addlast(general)
{
field(Facebook;Facebook)
{
CaptionML=ENU='Facebook';
}
}
}

actions
{
addlast("&Customer")
{
action("Get Facebook posts")
{
RunObject=codeunit "Social Media Mgt.";
RunPageOnRec = True;
Image = CheckDuplicates;
PromotedCategory = Category8;
Promoted = true;
ApplicationArea = All;
}
}
}
}