Hello, I am trying to Create a Duplicate Rule from the metadataService :
DuplicateRule :
public class DuplicateRule extends Metadata {
public String type = 'DuplicateRule';
public String actionOnInsert;
public String actionOnUpdate;
public String alertText;
public String description;
public MetadataService.DuplicateRuleFilter duplicateRuleFilter;
public MetadataService.DuplicateRuleMatchRule[] duplicateRuleMatchRules;
public Boolean isActive;
public String masterLabel;
public String[] operationsOnInsert;
public String[] operationsOnUpdate;
public String securityOption;
public Integer sortOrder;
private String[] actionOnInsert_type_info = new String[]{'actionOnInsert',SOAP_M_URI,null,'1','1','false'};
private String[] actionOnUpdate_type_info = new String[]{'actionOnUpdate',SOAP_M_URI,null,'1','1','false'};
private String[] alertText_type_info = new String[]{'alertText',SOAP_M_URI,null,'1','1','true'};
private String[] description_type_info = new String[]{'description',SOAP_M_URI,null,'1','1','true'};
private String[] duplicateRuleFilter_type_info = new String[]{'duplicateRuleFilter',SOAP_M_URI,null,'1','1','true'};
private String[] duplicateRuleMatchRules_type_info = new String[]{'duplicateRuleMatchRules',SOAP_M_URI,null,'0','-1','true'};
private String[] isActive_type_info = new String[]{'isActive',SOAP_M_URI,null,'1','1','false'};
private String[] masterLabel_type_info = new String[]{'masterLabel',SOAP_M_URI,null,'1','1','false'};
private String[] operationsOnInsert_type_info = new String[]{'operationsOnInsert',SOAP_M_URI,null,'0','-1','false'};
private String[] operationsOnUpdate_type_info = new String[]{'operationsOnUpdate',SOAP_M_URI,null,'0','-1','false'};
private String[] securityOption_type_info = new String[]{'securityOption',SOAP_M_URI,null,'1','1','false'};
private String[] sortOrder_type_info = new String[]{'sortOrder',SOAP_M_URI,null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{SOAP_M_URI,'true','false'};
private String[] type_att_info = new String[]{'xsi:type'};
private String[] field_order_type_info = new String[]{'actionOnInsert','actionOnUpdate','alertText','description','duplicateRuleFilter','duplicateRuleMatchRules','isActive','masterLabel','operationsOnInsert','operationsOnUpdate','securityOption','sortOrder'};
}
Creation of the MetaService :
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.timeout_x = 60000;
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
MetadataService.DuplicateRuleMatchRule dupMatchingRules = new MetadataService.DuplicateRuleMatchRule();
dupMatchingRules.matchRuleSObjectType = 'Lead';
dupMatchingRules.matchingRule = 'My_mathing_rule_name';
MetadataService.DuplicateRule dupRules = new MetadataService.DuplicateRule();
dupRules.actionOnInsert = 'Allow';
dupRules.actionOnUpdate = 'Allow';
dupRules.duplicateRuleMatchRules = new List<MetadataService.DuplicateRuleMatchRule>{dupMatchingRules};
dupRules.isActive = true;
dupRules.masterLabel = 'Lead duplicate rule';
dupRules.securityOption = 'EnforceSharingRules';
dupRules.sortOrder = 2;
List<MetadataService.Metadata> meta = new List<MetadataService.Metadata>{dupRules};
MetadataService.SaveResult results = service.createMetadata(meta)[0];
When I launch this code, in 'results' there is no error, but the 'results .success' is at false.
I don't know where the probleme is.
Hello, I am trying to Create a Duplicate Rule from the metadataService :
DuplicateRule :
Creation of the MetaService :
When I launch this code, in 'results' there is no error, but the 'results .success' is at false. I don't know where the probleme is.
I hope that someone can help me.