0

I have a requirement to grant FLS to the certain fields on profile level. I want to achieve this using Salesforce Metadata API thru java. I came across the below code for updating FLS using metadataservice class.

MetadataService.MetadataPort service = createService(); 
MetadataService.Profile admin = new MetadataService.Profile(); 
admin.fullName = 'Admin'; 
admin.custom = false; 
MetadataService.ProfileFieldLevelSecurity fieldSec = 
    new MetadataService.ProfileFieldLevelSecurity();
fieldSec.field='Test__c.TestField__c'; 
fieldSec.editable=true; 
admin.fieldPermissions = 
    new MetadataService.ProfileFieldLevelSecurity[] {fieldSec};
List<MetadataService.SaveResult> results =
 service.updateMetadata(new MetadataService.Metadata[] { admin });

So I have generated metadata.jar file from metadata.wsdl and imported into my project then I tried with that code but I couldn't find MetadataService class in my metadata.jar.

Can anyone help me why I can't access this class?

3
  • Did you add the JAR to your Build Path? Did you use the correct import statement(s)?
    – sfdcfox
    Feb 23, 2018 at 5:42
  • @sfdcfox - Yes, added jar file in build path and imported everything in a single statement as import com.sforce.soap.metadata.*; Do I need to import anything else?
    – Arosh
    Feb 23, 2018 at 5:52
  • For information, I have generated jar file using force-wsc-34.0.jar file
    – Arosh
    Feb 23, 2018 at 5:56

0

You must log in to answer this question.