Skip to content

Custom Sort Rules#

For unique business requirements not covered by pre-defined rules, create custom Sort Rules and then add them to a Sort Rule Set.

Create the DEE Rule#

Create a Dynamic Execution Engine (DEE) rule that implements the custom sorting logic required by the business scenario.

Screenshot showing a DEE action used to implement custom sort rule logic.

Create the Rule#

Create a Rule with one of the following scopes and assign the DEE to it:

  • SortRuleSetMaterial
  • SortRuleSetResource

Screenshot showing a rule configured with a sort rule set scope.

Example DEE Rule#

UseReference("", "Cmf.Foundation.Common");
UseReference("", "Cmf.Foundation.Common.Exceptions");
UseReference("Cmf.Foundation.BusinessObjects.dll", "Cmf.Foundation.BusinessObjects");
UseReference("Cmf.Navigo.BusinessObjects.dll", "Cmf.Navigo.BusinessObjects");
UseReference("Cmf.Foundation.BusinessOrchestration.dll", "");

string attributeName = "MySortingAttribute";

if (!Input.ContainsKey("Material") || !(Input["Material"] is IMaterial))
{
    throw new ArgumentNullException("Material");
}

Dictionary<string, object> output = new Dictionary<string, object>();
IMaterial material = (IMaterial)Input["Material"];
material.LoadAttributes(new System.Collections.ObjectModel.Collection<string>() { attributeName });

if (material.Attributes.ContainsKey(attributeName))
{
    output["Result"] = material.Attributes[attributeName];
}
else
{
    output["Result"] = string.Empty;
}

return output;

For more information, see our Developer Portal page for Custom Sort Rules in https://developer.criticalmanufacturing.com/explore/guides/customizations/business/customsortrules/ ⧉.

Create the Sort Rule Entity#

Create the Sort Rule entity that references the rule created in the previous step, and then add that Sort Rule to the target Sort Rule Set through Manage Rules.

Screenshot showing the sort rule entity referencing the custom rule.

Note

Custom rules require development expertise and should be thoroughly tested before being used in production dispatching scenarios.