Set-NAVApplicationObjectProperty

Set-NAVApplicationObjectProperty

Sets Microsoft Dynamics NAV application object properties in the specified application object text files.

Syntax

Parameter Set: Default
Set-NAVApplicationObjectProperty [-TargetPath] <String[]> [-DateTimeProperty <String> ] [-ModifiedProperty <SetModifiedPropertyAction> ] [-PassThru] [-VersionListProperty <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

Use the Set-NAVApplicationObjectProperty cmdlet to change the values of the Version List, Date, Time, or Modified properties in the specified text files. You can use the Get-NAVApplicationObjectProperty cmdlet to extract information about the application objects before you change them.

Parameters

-DateTimeProperty<String>

Specifies the value of the Date and Time properties that you want to apply to the specified application objects, such as 01-01-2016. You must specify date and time according to the locale of the computer that you are running Microsoft Dynamics NAV 2016 Development Shell on. For example, you can use the Get-Date Windows PowerShell cmdlet to get the date before you set the parameter, such as by typing the following command:

Get-Date -Format g

For more information, see the example section.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-ModifiedProperty<SetModifiedPropertyAction>

Sets a value for the Modified property for the application object. The following options are available:

Yes

The Modified property is set to Yes.

No

The Modified property is set to No.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-PassThru

Specifies if the cmdlet must return an object that contains the application object properties for each updated application object. If you do not set this parameter, the cmdlet returns a list of the changes.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-TargetPath<String[]>

Specifies the folder where the application objects are stored that you want to update. You can specify a single text file or all text files in the specified folder.

Aliases

PSPath,Target

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

True (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-VersionListProperty<String>

Sets the Version List property for the application objects. You can specify a value that will overwrite any existing values. For example, use a command such as the following:

Set-NavApplicationObjectProperty - TargetPath .\COD1.txt -VersionListProperty "MyUpdate"

Alternatively, you can get the property values from the objects first and then add a new value.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

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, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters.

Examples

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

Description

-----------

This example sets new the values for the Version List, Date, Time, and Modified properties in the specified target file. The date and time is set to the current date and time. When the update completes, the status is shown, including the updated values of the properties.

PS C:\> Set-NAVApplicationObjectProperty -TargetPath .\COD1.txt -VersionListProperty "DemoV1" -ModifiedProperty Yes -DateTimeProperty (Get-Date -Format g)

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

Description

-----------

This example sets a new value for the Date and Time properties in the specified target file. The date and time is set to a specific, locale-agnostic date and time, January 1st, 2015. When the update completes, the status is shown, including the updated values of the properties.

PS C:\> Set-NAVApplicationObjectProperty -TargetPath .\COD1.TXT -DateTimeProperty (Get-Date -Year 2016 -Month 1 -Day 1 -Hour 0 -Minute 0 -Format g) }

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

Description

-----------

This example sets a new value for the Date and Time properties in the target files that are passed through by the Merge-NAVApplicationObject cmdlet. The date and time is set to a specific, locale-agnostic date and time, January 1st, 2016. When the update completes, the status is shown, including the updated values of the properties.

PS C:\> Merge-NAVApplicationObject -OriginalPath .\ORIGINAL\*.txt -ModifiedPath .\MODIFIED\*.txt -TargetPath .\TARGET\*.txt -ResultPath .\RESULT -Force -PassThru |
    Where-Object MergeResult –eq 'Merged' |
    foreach { Set-NAVApplicationObjectProperty -TargetPath $_.ResultPath -DateTimeProperty (Get-Date -Year 2016 -Month 1 -Day 1 -Hour 0 -Minute 0 -Format g) }

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

Description

-----------

This example merges application objects, gets the VersionList property for the same application object in three different versions, and then sets a new value for the version list. When the update completes, the status is shown, including the updated values of the properties.

PS C:\> $result = Merge-NAVApplicationObject -OriginalPath .\ORIGINAL\*.txt -ModifiedPath .\MODIFIED\*.txt -TargetPath .\TARGET\*.txt -ResultPath .\RESULT -Force 
$result | 
(Get-NAVApplicationObjectProperty -Source .\MODIFIED\COD9999.txt).VersionList
(Get-NAVApplicationObjectProperty -Source .\TARGET\COD9999.txt).VersionList
(Get-NAVApplicationObjectProperty -Source .\RESULT\COD9999.txt).VersionList

    Where-Object MergeResult –eq 'Merged' | 
    foreach { Set-NAVApplicationObjectProperty -TargetPath $_.Result -VersionListProperty ($_.Modified.VersionList + "," + $_.Target.VersionList + "!"); 
              Get-NAVApplicationObjectProperty -Source $_.Result }