< Back

Get-ALExtensionFilesInfo

Sat Jan 18, 2020 4:59 pm

NAME Get-ALExtensionFilesInfo



SYNOPSIS

This function allows you to get information about Nav(Business Central) AL Extension files.





SYNTAX

Get-ALExtensionFilesInfo [-ALExtensionFiles] <Array> [-GetIDFromExtensionName] [-GetObjectNameFromFileName]

[-GetFreeIds] [<CommonParameters>]





DESCRIPTION

In AL VS Code Extensions V2, if you try to create an extension and the ID or Name are already used, you get an

error.

If you don't have the IDs of the files in the file name it is difficult to know what ID each extension has.

This function will show for each extension file the ID, the name of the object that it extends and the extension

type.

You can also check what Ids are not used.





PARAMETERS

-ALExtensionFiles <Array>

This is a mandatory parameter and it should be an array of FileInfo objects (Use function Get-ChildItem to Get

array of FileInfo objects with

the folders where you have your extension files.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-GetIDFromExtensionName [<SwitchParameter>]

You can use this switch in case you have the ID of the extension in the extension name.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-GetObjectNameFromFileName [<SwitchParameter>]

You can use this switch in case you have the name of the object that the extension extends in the file name.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-GetFreeIds [<SwitchParameter>]

Use this switch in case you want the function to return only the free Ids. For example if you have two page

extensions with IDs 50251 and 50254, the function can show you

that Ids 50252 and 50253 are not used.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

None.





OUTPUTS

The return Type is an Array of PSCustomObjects.





-------------------------- EXAMPLE 1 --------------------------



PS>$Folder = 'C:\\ALExtensionIdsSample\\Folder 1'



$Folder2 = 'C:\\ALExtensionIdsSample\\Folder 2'

$Files = Get-ChildItem $Folder -Filter '*.al'

$Files += Get-ChildItem $Folder2 -Filter '*.al'



#get the info from extension files

$ExtensionInfo = Get-ALExtensionFilesInfo -ALExtensionFiles $Files

$ExtensionInfo



This example gives you information about the extension files:

ObjectName ExtensionNumber FileName

ExtensionType

---------- --------------- --------

-------------

Posted Purchase Invoices 50292 C:\\ALExtensionIdsSample\\Folder 1\\PEX - Posted Purchase Invoices.al

pageextension

Workflow 50295 C:\\ALExtensionIdsSample\\Folder 1\\PEX - Workflow.al

pageextension









-------------------------- EXAMPLE 2 --------------------------



PS>Get-ALExtensionFilesInfo -ALExtensionFiles $Files -GetFreeIds



This example generates a list with Ids that are not used:

ExtensionNumber ExtensionType

--------------- -------------

50293 pageextension

50294 pageextension









-------------------------- EXAMPLE 3 --------------------------



PS>$MaxMinNo = $ExtensionInfo |



Where-Object{$_.ExtensionType -like 'pageextension'} |

Measure-Object -Property ExtensionNumber -Maximum -Minimum

$ExtensionInfo | Where-Object {($_.ExtensionNumber -eq $MaxMinNo.Maximum) -and

($_.ExtensionType -like 'pageextension')}



This example gives you the maximum used id for page extensions









-------------------------- EXAMPLE 4 --------------------------



PS>$ExtensionInfo | Where-Object{($_.ObjectName -like 'Transfer Order') -and



($_.ExtensionType -like 'pageextension')}



This example gives you the id of the extension that extends page Transfer Order.









-------------------------- EXAMPLE 5 --------------------------



PS>$ExtensionInfo | Where-Object{($_.ExtensionNumber -eq 50292) -and



($_.ExtensionType -like 'pageextension')} |

Select-Object -Property ObjectName



This example gives you the Nav object name that extension with Id 50292 extends











RELATED LINKS

http://andreilungu.com/nav-al-extension-files-info