Hi Team,
Could you please let me know what would be the proper way to filter DOM objects?
Example use case, i want to know is an upgrade object with some specific properties is already present to determine whether i should create a new one or update it.
currently using this code:
public static DomInstance GetUpgrade(this UpgradeModule upgradeModule, UpgradeFieldsGeneralValues upgrade)
{
var customerDescriptorId = UpgradeDomDefinition.UpgradeSectionGeneralInfo.FieldDescriptors.CustomerDcpId.ID;
var customerFilter = DomInstanceExposers.FieldValues.DomInstanceField(customerDescriptorId).Equal(upgrade.CustomerDcpId);var dmaDescriptorId = UpgradeDomDefinition.UpgradeSectionGeneralInfo.FieldDescriptors.DmaId.ID;
var dmaFilter = DomInstanceExposers.FieldValues.DomInstanceField(dmaDescriptorId).Equal(upgrade.DmaId);var previousVersionDescriptorId = UpgradeDomDefinition.UpgradeSectionGeneralInfo.FieldDescriptors.PreviousVersion.ID;
var previousVersionFilter = DomInstanceExposers.FieldValues.DomInstanceField(previousVersionDescriptorId).Equal(upgrade.PreviousVersion);var newVersionDescriptorId = UpgradeDomDefinition.UpgradeSectionGeneralInfo.FieldDescriptors.NewVersion.ID;
var newVersionFilter = DomInstanceExposers.FieldValues.DomInstanceField(newVersionDescriptorId).Equal(upgrade.NewVersion);var filter = customerFilter.AND(dmaFilter).AND(previousVersionFilter).AND(newVersionFilter);
return upgradeModule.DomHelper.DomInstances.Read(filter).FirstOrDefault();
}
as reference i'm using: https://docs.dataminer.services/user-guide/Advanced_Modules/DOM/DOM_examples/DOM_Invoice_app_example.html#readingfiltering-dom-instances
thanks in advance
Hi Julio,
Does the code you posted work for your use case? Because from what I can tell, it looks correct. You need to define separate filters for all the conditions that should be met and then merge them in an 'AND' filter. The only recommendation I would have is to pass the individual filtering to the constructor of the ANDFilterElement. But in the end, it doesn't matter all that much.
thank you very much Thomas yes it works, just wanted to verify if it was a proper approach