Invoke-NAVCodeunit
Invokes the specified codeunit with the specified parameters.
Syntax
Invoke-NAVCodeunit
[-Tenant <TenantId>]
[-CompanyName <String>]
-CodeunitId <Int32>
[-MethodName <String>]
[-Argument <String>]
[-Language <LanguageSetting>]
[-TimeZone <InvokeCodeunitTimeZone>]
[-ServerInstance] <String>
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
You must specify a codeunit and a Microsoft Dynamics NAV Server instance. Optionally, you can specify other parameters. By default, the OnRun trigger is called, but you can specify a different method name and pass it an optional string argument. You can run the codeunit within the scope of a company, a tenant, or both. Optionally, you can specify the language that you want to use when you invoke the codeunit. Return values are ignored.
Examples
EXAMPLE 1
Invoke-NAVCodeunit -ServerInstance DynamicsNAV -CompanyName 'CRONUS International Ltd.' -CodeunitId 100000 -Language 'da-DK'
This example invokes codeunit 100000 and calls the OnRun trigger because no other method is specified. The code runs with Danish language settings in the CRONUS International Ltd. company in the Microsoft Dynamics NAV Server instance DynamicsNAV.
EXAMPLE 2
Invoke-NAVCodeunit -ServerInstance DynamicsNAV -Tenant Tenant1 -CompanyName MyCompanyName -CodeunitId 2
The example invokes codeunit 2, which initializes the MyCompanyName company.
EXAMPLE 3
Invoke-NAVCodeunit -ServerInstance DynamicsNAV -Tenant Tenant1 -CompanyName MyCompanyName -CodeunitId 104048 -MethodName "UpgradeStep2"
The example runs the UpgradeStep2 method in codeunit 104048, which is part of the Upgrade Toolkit for Microsoft Dynamics NAV.
Parameters
-Argument
Specifies a string argument that is passed to the specified method on the codeunit.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-CodeunitId
Specifies the ID of the codeunit that you want to invoke. The Invoke-NAVCodeunit cmdlet calls the OnRun trigger in the specified codeunit. You can call another method if you specify it in the MethodName parameter.
Type: | Int32 |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-CompanyName
Specifies the name of the company that you want to run the codeunit in. If you do not set this parameter, the codeunit will run in the default company for the Microsoft Dynamics NAV Server instance.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Force
Forces the command to run without asking for user confirmation.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Language
Specifies the language that the codeunit will run in. You must specify a valid culture name for a language in Microsoft Dynamics NAV, such as en-US or da-DK. If the specified language does not exist on the Microsoft Dynamics NAV Server instance, the codeunit will run in en-US.
Type: | LanguageSetting |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-MethodName
Specifies the method that will be called. If no method is specified, the OnRun trigger is called.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ServerInstance
Specifies the name of a Dynamics NAV Server instance, for example, DynamicsNAV or myinstance. You can specify either the full name of an instance, such as MicrosoftDynamicsNavServer$myinstance or the short name such as myinstance.
Type: | String |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Tenant
Specifies the ID of the tenant that you want to invoke the codeunit in, such as Tenant1.
This parameter is required unless the specified service instance is not configured to run multiple tenants.
Type: | TenantId |
Aliases: | Id |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-TimeZone
Specifies the time zone that the invoked codeunit will use for date calculations. You can set the parameter to the following values:
Utc - Uses Universal Coordinated Time (UTC) as the time zone. This is the default value. If you do not set this parameter, then UTC is used.
ClientTimezone - Uses the time zone that is configured for the computer on which the cmdlet is run.
TenantTimezone - Uses the default time zone that is configured for the tenant. The tenant's time zone is configured when the tenant is mounted on the Microsoft Dynamics NAV Server instance. This is only relevant when the Microsoft Dynamics NAV Server instance is configured as a multitenant instance.
ServicesDefaultTimeZone - Uses the default time zone that is configured web services on the Microsoft Dynamics NAV Server instance.
Type: | InvokeCodeunitTimeZone |
Accepted values: | Utc, ClientTimeZone, TenantTimeZone, ServicesDefaultTimeZone |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |