I wanted to update FLS for the custom fields in Profile level.
@datasert- Thanks for guided me on the right path, I have tried with the code below but after executed the code, changes are not reflecting means FLS is not set as given in code, below is the code I tried
Profile admin = new Profile();
admin.setFullName("Test");
admin.setCustom(false);
ProfileFieldLevelSecurity fieldSec = new ProfileFieldLevelSecurity();
fieldSec.setField("Lead.identitify__TriggerCount__c");
fieldSec.setEditable(false);
fieldSec.setReadable(true);
admin.setFieldPermissions(new ProfileFieldLevelSecurity[]{fieldSec});
System.out.println("dddddddddddddd"+admin);
SaveResult[] results = metadataConnection.updateMetadata(new Metadata[] { admin });
for (SaveResult r : results) {
if (r.isSuccess()) {
System.out.println("Updated component: " + r.getFullName());
}
}
Note: I'm seeing the last modified date/time in Profile with my name but field level security is not set for the given fields. Please let me know if I missing anything.
Thanks in Advance!
wsdlc
for the v42.0 release? There is also the force-metadata-api, which may be more appropriate for working with the Metadata API.