You need to sign in to do that
Don't have an account?
field creation & deletion through metadata api
Hi,
My requirement is to delete an existing value from picklist, for that i am using Metadata API but still i am not able to perform deletion.
I have created Metadata Service class and added respective method related to deletion and invoking delete operation through Batch for the time being i have hard coded few values like field name.
Any help will be appriciated.
My requirement is to delete an existing value from picklist, for that i am using Metadata API but still i am not able to perform deletion.
I have created Metadata Service class and added respective method related to deletion and invoking delete operation through Batch for the time being i have hard coded few values like field name.
Any help will be appriciated.
//Batch Class code global class UpdatePicklistBatchJob1 implements Database.Batchable<sObject>, Database.AllowsCallouts { global String sessionId; global UpdatePicklistBatchJob1(String sId) { sessionId = sId; } global Database.QueryLocator start(Database.BatchableContext bc) { return Database.getQueryLocator('SELECT Object__c, Picklist_New__c, Picklist_Old__c from Picklist_Config__c WHERE Status__c =\'Ready To Process\''); } global void execute(Database.BatchableContext bc, List<Picklist_Config__c> configs) { MetadataSrv.MetadataPort service = new MetadataSrv.MetadataPort(); service.SessionHeader = new MetadataSrv.SessionHeader_element(); service.SessionHeader.sessionId = sessionId; // UserInfo.getSessionId(); // Read Custom Field MetadataSrv.CustomField customField = (MetadataSrv.CustomField) service.readMetadata('CustomField', new String[] { 'Demo__c.Alternate_Email__c' }).getRecords()[0]; List<MetadataSrv.DeleteResult> results = service.deleteMetadata('CustomField', new String[] { 'Demo__c.Alternate_Email__c' }); } global void finish(Database.BatchableContext bc) { } }
<pre>
UpdatePicklistBatchJob1 job = new UpdatePicklistBatchJob1();
job.UpdatePicklistBatchJob1( UserInfo.getSessionId() );
List<Picklist_Config__c> configs =
[ SELECT Object__c, Picklist_New__c, Picklist_Old__c
FROM Picklist_Config__c
WHERE Status__c = 'Ready To Process'
];
job.execute( null, configs );
</pre>
I am executing this from Anonymous window only and i am not getting any error or exception.
It just not fulfilling the requirement.