Sunday 24 September 2017

Rearrange fields in New/Edit form of lists

The fields in the New/Edit form of a list are attached to the ContentType.
If you want to rearrange the same. You can do the same in code (Server Object Model/Powershell).

The code is simple but, small mistake you can make :)
Note : Please note the field names should be "Internal Names"


$ct = $list.ContentTypes["Content Type Name"];
if($ct -ne $null)
{
    try
        {
             $fldOrder = "Title", "Field1", "Field2", "Field3";  # Should be Internal Names
     $ct.FieldLinks.Reorder($fldOrder);
     $ct.Update();
}
     catch { write-host "Error: " $_.Exception.Message }
}

No comments:

Post a Comment