You need to sign in to do that
Don't have an account?

Update Profile via Metadata API
Hi All,
I am trying to update Profile using Metadata API in Apex Class:
MetadataService.IReadResult resultValue = service.readMetadata(metadataType,new List<String>{'ContractManager'});
for(MetadataService.Metadata md: resultValue.getRecords())
{
MetadataService.Profile pr = new MetadataService.Profile();
pr = (MetadataService.Profile)md;
for(MetadataService.ProfileApexClassAccess pop: pr.classAccesses)
{
if(pop.apexClass == 'TestApexClass')
pop.enabled = true;
}
for(MetadataService.ProfileApplicationVisibility pvp: pr.applicationVisibilities)
{
if(pvp.application== 'TestApplication')
pvp.visible= true;
}
MetadataService.Saveresult[] results = service.updateMetadata(new MetadataService.Metadata[] {pr});
Above saveResult is not returning any error. But the "success" variable is showing false. Am I missing anything in the above code?
Is it possible to make Profile updates via Metadata API?
Thanks
Sureka
I am trying to update Profile using Metadata API in Apex Class:
MetadataService.IReadResult resultValue = service.readMetadata(metadataType,new List<String>{'ContractManager'});
for(MetadataService.Metadata md: resultValue.getRecords())
{
MetadataService.Profile pr = new MetadataService.Profile();
pr = (MetadataService.Profile)md;
for(MetadataService.ProfileApexClassAccess pop: pr.classAccesses)
{
if(pop.apexClass == 'TestApexClass')
pop.enabled = true;
}
for(MetadataService.ProfileApplicationVisibility pvp: pr.applicationVisibilities)
{
if(pvp.application== 'TestApplication')
pvp.visible= true;
}
MetadataService.Saveresult[] results = service.updateMetadata(new MetadataService.Metadata[] {pr});
Above saveResult is not returning any error. But the "success" variable is showing false. Am I missing anything in the above code?
Is it possible to make Profile updates via Metadata API?
Thanks
Sureka