Column Preferences Migration Script

This script migrates custom column data from the Planners - Resource, Planners - Project, and Project Task Gantt Settings custom settings into custom sObjects. For details on use, see Configuring Custom Columns with a Custom Object and Migrating Column Preferences from Custom Settings to Custom Objects.

You must have administrator access in your organization to use this script.

Migration Script

//PACKAGED VERSION
//Delete any existing records in the sObject before starting the import process
//delete [select id from pse__Column_Preferences__c];


//Repeat this anon apex as needed to migrate All custom settings (4000 records per execution)
list<pse__ColumnPreferences__c> csList = 
   [SELECT name,pse__Width__c,pse__Order__c,pse__Field__c,pse__Visible__c,pse__Value__c
FROM pse__ColumnPreferences__c
    LIMIT 4000
];


String prefix = Schema.SObjectType.User.keyPrefix;
list<pse__Column_Preferences__c> soList = new list<pse__Column_Preferences__c>(); 

for (pse__ColumnPreferences__c cs : csList)
{
   pse__Column_Preferences__c so = new pse__Column_Preferences__c();
   so.pse__User__c     = prefix + cs.Name.substring(0,15);
   so.pse__Feature__c  = cs.Name.substring(15,16);
   so.pse__Width__c    = cs.pse__Width__c;
   so.pse__Order__c    = cs.pse__Order__c;
   so.pse__Field__c    = cs.pse__Field__c;
   so.pse__Visible__c  = cs.pse__Visible__c;
   so.pse__Value__c    = cs.pse__Value__c;
   soList.add(so);
}

insert soList;
delete csList;

© Copyright 2009-2018 FinancialForce.com, inc. All rights reserved.
Various trademarks held by their respective owners.