function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Tejender Mohan 9Tejender Mohan 9 

Not able to update Assignment Rule using Update Metadata API call.

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".

 
DR9DR9
Hi Tejinder, were you able to do solve this problem?
Tejender Mohan 15Tejender Mohan 15

Hello Deepak

The issue is still not solved. 

I raised a case with Salesforce, they created a known issue and that is still not fixed.

https://trailblazer.salesforce.com/issues_view?id=a1p3A000001GebvQAC

DR9DR9
Thanks for the update, Tejinder and known issue link. However, Is there any alternate method and example through which I could acheive the same?