public class DeveloperUtility { public static List CreateFields(string sobject_name,string [] fields){ List results = new List(); for(string f : fields){ string old_label = f.removeEnd('__c').replace('_',' '); string label = old_label + ' Encrypted'; string name = label.replace(' ','_')+'__c'; string description = ''; system.debug('old_label='+old_label); system.debug('label='+label); system.debug('name='+name); results.add(CreateField(sobject_name,label,name,description,'Text')); } return results; } public static HTTPResponse CreateField(string sobject_name, string label,string name,string description,string type){ HTTP h = new HTTP(); HTTPRequest req = new HTTPRequest(); req.setMethod('POST'); req.setHeader('Content-Type', 'text/xml'); req.setHeader('SOAPAction', 'create'); //string sobject_name = 'Contact'; //string label = 'Title'; //string name = 'Title'+'_Encrypted__c'; //string description = ''; //string type = 'Text'; boolean typeSpecified = true; String b = ''; b += ''; b += ''; b += ''; b += '' + UserInfo.getSessionId() + ''; b += ''; b += ''; b += ''; b += ''; b += ''; b += ''+type+''; b += ''+sobject_name+'.'+name+''; b += ''; b += '255'; b += ''+type+''; b += ''; b += ''; b += ''; b += ''; req.setBody(b); req.setCompressed(false); req.setEndpoint('https://ocsm--pipl.my.salesforce.com/services/Soap/m/25.0'); HTTPResponse resp = h.send(req); System.debug(resp.getBody()); return resp; } }