Table of Contents

Rule Action Type

Interface: interface "PIMX Rule Action Type c1"
Enum: enum 70113797 "PIMX Rule Action Type"

When to use

Use this interface when you need to add an action to the Features rule engine. The action type is selected in a rule definition, can expose and validate its parameters, and is executed after the rule condition is satisfied; for example, it can update a related product feature when an item value changes.

HIDDEN

DevOps sources: #36792, #17797

Use the interface

Implement the interface in a codeunit and register it in PIMX Rule Action Type. Create only the parameters required by the action, validate them before execution, and use SourceRec, MasterRec, and Data according to the rule context. Keep GetDescription short because it is displayed with the configured rule.

Extend enum PIMX Rule Action Type to register the implementation.

codeunit 50000 "Custom Rule Action" implements "PIMX Rule Action Type c1"
{
	procedure CreateParameters(TableNumber: Integer; var Parameters: Dictionary of [Text, Text])
	begin
		Parameters.Add('Value', '');
        //Add more
	end;

	procedure ValidateParameterValue(Name: Text; Value: Text)
	begin
		if Value = '' then
			Error('The %1 parameter cannot be empty.', Name);
	end;

	procedure LookupParameterValue(Parameter: Record "PIMX Rule Parameters"; var Value: Text)
	begin
		// Open a lookup and assign the selected value when needed.
	end;

	procedure GetDescription(Parameters: Dictionary of [Text, Text]): Text
	begin
		exit('Custom rule action');
	end;

	procedure Execute(SourceRecord: Variant; MasterRecord: Variant; Parameters: Dictionary of [Text, Text]; Data: Codeunit "PIMX Rule Data")
	begin
		// Apply the action to the source or master record.
	end;
}

Implementation considerations

Before implementing a custom rule action, create an AL project with the Pimics dependency and download the symbols. The action should:

  • Check the source and master records before changing data.
  • Validate all configured parameters before execution.
  • Assign values to the required records, either from fixed values or by looking them up from the source record.
  • Use values from previous rule actions only where the supported rule data is available.

When a rule action is implemented as an extension, do not rely on unavailable rule data. Product feature data is available to the extension, but other rule data may not be available in the execution context.

TODO

The former Custom Rule Implementation page contained a concrete Assign Vendor example. Add a scenario-specific example here if a concrete vendor-assignment implementation is still required.