• DR9
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
I have been trying to update the Assignment Rule's Rule Entry assignTo field using UpdateMetadata Call. I have tried several ways but still not able to update it. Can someone please suggest any solution? Below is the code snippet :
MetadataService.IReadResult readResult = new MetadataService.ReadAssignmentRulesResult();

readResult = service.readMetadata('AssignmentRules', new String[]{'Lead'}); 

MetadataService.Metadata[] mdInfo = readResult.getRecords(); 

MetadataService.AssignmentRules TempAssignmentRules = (MetadataService.AssignmentRules) mdInfo[0];

 System.debug('Assignment Rule Name :---> '+ TempAssignmentRules.AssignmentRule[0].fullname); 

System.debug('Assigneee Name :---> '+TempAssignmentRules.AssignmentRule[0].ruleEntry[0].assignedTo);

 //Updating Value Here 
TempAssignmentRules.AssignmentRule[0].ruleEntry[0].assignedTo='teXYZ.com'; 
//Update 
MetadataService.SaveResult[] results = service.updateMetadata(new MetadataService.Metadata[] { TempAssignmentRules});
 System.debug('ERROR : '+ results[0].errors[0].message); //Error is "unexpected metadata".