none
ProjectServer - Regional settings change problem RRS feed

  • Question

  • We are unable to change project server "Regional Settings" -> "Locale" to Croatian
    Because "Project Server Workflow Tasks" and "Project Server Workflow History" lists have indexes.

    then we:

    1. dropped "Project Server Workflow History" index "Workflow History Parent Instance"
    2. dropped "Project Server Workflow Tasks" index "Instance Id"
    3. changed "Locale"
    4. recreated "Project Server Workflow History" index "Workflow History Parent Instance"
    5. but were unable to recreate "Project Server Workflow Tasks" index "Instance Id" because "Instance Id" is not in list of columns

    Is there ay other way to recreate Index ? (like powershell)

    Thanks,

    D

    Tuesday, February 9, 2016 2:00 AM

Answers

  • We managed to recreate index using powershell from

    https://gallery.technet.microsoft.com/office/PowerShell-Script-for-0117b567

    ---- FULL CODE SLIGHTLY CHANGED --

    Start-SPAssignment
    $subsite = Get-SPWeb http://MyTestPwa/PWA

    Function removeIndex ()
    {
    Param ($list,$InternalFldName)

        try
            {
            Write-Output "The searching  field $InternalFldName";

            $fldToIndex =$list.Fields.GetFieldByInternalName($InternalFldName);                                                 

            Write-Output "The field $fldToIndex has been found";

                try
                {
                   $index= $list.FieldIndexes.Item($fldToIndex.Id)
                   $fldToIndex.Indexed = $true;    
                   $list.FieldIndexes.Delete($fldToIndex.Id);
                   Write-Output ("The indexed {0} has been removed" -f $fldToIndex.Title) ;

                }
                catch
                {
                   Write-Output "The field $fldToIndex is already non-indexed"
                }

            }
        catch
            {
             $error[0]
            }

    }


    Function AddIndex ()
    {
    Param ($list,$InternalFldName)

        try
            {
            Write-Output "The searching  field $InternalFldName";

            #$fldToIndex =$list.Fields.GetFieldByInternalName($InternalFldName);                                                 
    $fldToIndex =$list.Fields[$InternalFldName];                                                 

            Write-Output "The field $fldToIndex has been found";

                try
                {
                   $index= $list.FieldIndexes.Item($fldToIndex.Id)
                   Write-Output "The field $fldToIndex is already indexed"
                }
                catch
                {
                    $fldToIndex.Indexed = $true;    
                    $list.FieldIndexes.Add($fldToIndex);
                    Write-Output ("The field {0} has been indexed" -f  $fldToIndex.Title);
                }

            }
        catch
            {
             $error[0]
            }

    }

    $listsToIndex = @{
    "Project Server Workflow Tasks"="Instance Id";
    }
    foreach ($lstToIndex in $listsToIndex.GetEnumerator())
    {

    Write-Output ( "Index  {0} for list {1} ..." -f $lstToIndex.Value,  $lstToIndex.Key );


    $lst = $subsite.Lists[$lstToIndex.Key]
    $InternalFldName=$lstToIndex.Value

    if (($lst -ne $null) -and ($InternalFldName -ne $null))
    {
        #removeIndex  $lst $InternalFldName
        addIndex $lst $InternalFldName
        write-Output "InternalFldName: $InternalFldName"
     }
    else
    {
        Write-Output "The predefined list has error for $lst"
    }

    }

                   
    • Marked as answer by MR - D Tuesday, February 9, 2016 2:16 AM
    Tuesday, February 9, 2016 2:16 AM

All replies

  • We managed to recreate index using powershell from

    https://gallery.technet.microsoft.com/office/PowerShell-Script-for-0117b567

    ---- FULL CODE SLIGHTLY CHANGED --

    Start-SPAssignment
    $subsite = Get-SPWeb http://MyTestPwa/PWA

    Function removeIndex ()
    {
    Param ($list,$InternalFldName)

        try
            {
            Write-Output "The searching  field $InternalFldName";

            $fldToIndex =$list.Fields.GetFieldByInternalName($InternalFldName);                                                 

            Write-Output "The field $fldToIndex has been found";

                try
                {
                   $index= $list.FieldIndexes.Item($fldToIndex.Id)
                   $fldToIndex.Indexed = $true;    
                   $list.FieldIndexes.Delete($fldToIndex.Id);
                   Write-Output ("The indexed {0} has been removed" -f $fldToIndex.Title) ;

                }
                catch
                {
                   Write-Output "The field $fldToIndex is already non-indexed"
                }

            }
        catch
            {
             $error[0]
            }

    }


    Function AddIndex ()
    {
    Param ($list,$InternalFldName)

        try
            {
            Write-Output "The searching  field $InternalFldName";

            #$fldToIndex =$list.Fields.GetFieldByInternalName($InternalFldName);                                                 
    $fldToIndex =$list.Fields[$InternalFldName];                                                 

            Write-Output "The field $fldToIndex has been found";

                try
                {
                   $index= $list.FieldIndexes.Item($fldToIndex.Id)
                   Write-Output "The field $fldToIndex is already indexed"
                }
                catch
                {
                    $fldToIndex.Indexed = $true;    
                    $list.FieldIndexes.Add($fldToIndex);
                    Write-Output ("The field {0} has been indexed" -f  $fldToIndex.Title);
                }

            }
        catch
            {
             $error[0]
            }

    }

    $listsToIndex = @{
    "Project Server Workflow Tasks"="Instance Id";
    }
    foreach ($lstToIndex in $listsToIndex.GetEnumerator())
    {

    Write-Output ( "Index  {0} for list {1} ..." -f $lstToIndex.Value,  $lstToIndex.Key );


    $lst = $subsite.Lists[$lstToIndex.Key]
    $InternalFldName=$lstToIndex.Value

    if (($lst -ne $null) -and ($InternalFldName -ne $null))
    {
        #removeIndex  $lst $InternalFldName
        addIndex $lst $InternalFldName
        write-Output "InternalFldName: $InternalFldName"
     }
    else
    {
        Write-Output "The predefined list has error for $lst"
    }

    }

                   
    • Marked as answer by MR - D Tuesday, February 9, 2016 2:16 AM
    Tuesday, February 9, 2016 2:16 AM
  • You can change the "Regional Settings" -> "Locale" to any country you prefer and keep the "Sort Order" to "General".

    This worked for me.

    Friday, March 8, 2019 11:46 AM