• Hayat Ansari 12
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I have a below class which add custom picklist value using MetaDataService class but I am stuck in writing test coverage for the same.
 
public class GenerateMetaData {
    
    Public static void GenerateLeadStatusValueL(){
        String picklistapiname = 'Lead.Status__c';
        MetadataService.MetadataPort service = new MetadataService.MetadataPort();   
        service.SessionHeader = new MetadataService.SessionHeader_element();
        service.SessionHeader.sessionId = UserInfo.getSessionId();
        
        system.debug('Session Id>>>'+UserInfo.getSessionId());
        
        MetadataService.CustomField customField = (MetadataService.CustomField) service.readMetadata('CustomField', new String[] { picklistapiname}).getRecords()[0];
        
        system.debug('customField>>>'+customField);
        // For each on: customField > Get valueset > Get valueSetDefinition > get values
        
        MetadataService.CustomValue value = new MetadataService.CustomValue();
        value.fullName = 'fruit12';
        value.default_x = false ;
        value.isActive = true;
        
        customField.valueSet.valueSetDefinition.value.add(value);
        // Update 
        List<MetadataService.SaveResult> lstResults = service.updateMetadata( new MetadataService.Metadata[] { customField });
        
        for (MetadataService.SaveResult objResult : lstResults) {
            if (objResult.success) {
                System.debug('Successfully updated');
            }
            else {                       
                if(objResult.errors.size() > 0){
                    System.debug('eror : ' + objResult.errors[0].message);
                }
            }
        }
        
    }
    
}

Please Help!!!
While at Dreamforce last month, I was struck with a blatently obvious by simple application that I am interested in developing but do not have the experience to do so myself. I am looking for a developer that would be able to help me out with:
  1. Writing the app
  2. Helping submit it to the App Exchange
  3. Maintaining the app if future updates are needed.
I have a expereince in managing software development for enterprise so I am confident that this app would not be large in nature. However I do not have any experience with the SF app exchange which is why I am looking for help on this.