You need to sign in to do that
Don't have an account?
gaurav arora 33
Lookup filter getting reset if i use Matadata API for setting the history tracking for lookup field
I am using the Below code to update the history tracking of lookup field to true
The code works fine. but the problem is if that lookup field has any lookup filter then that would get deleted.
is there any way to dynamically update the history tracking of lookup field and keeping the lokkup filters intact.
MetadataService.MetadataPort service = new MetadataService.MetadataPort(); service.SessionHeader = new MetadataService.SessionHeader_element(); service.SessionHeader.sessionId = UserInfo.getSessionId(); List<MetadataService.CustomField> cfList = new List<MetadataService.CustomField>(); MetadataService.CustomField customField = new MetadataService.CustomField(); customField.type_x = 'Lookup'; customField.fullName = 'Case_Contact__c.Account__c'; customField.label = 'Account'; customField.relationshipLabel = 'Case_Contacts'; customField.relationshipName = 'Case_Contacts'; customField.referenceTo = 'Account'; customField.trackHistory = true; cfList.add(customField); List<MetadataService.SaveResult> results = service.updateMetadata(cfList);
The code works fine. but the problem is if that lookup field has any lookup filter then that would get deleted.
is there any way to dynamically update the history tracking of lookup field and keeping the lokkup filters intact.