This was originally raised as a bug but this was the intended behaviour at the time of implementation, please see description of the problem below:
Description
Movement Lookup does not work when updating record using Submit Data Merge Criteria
Repro Steps
1. Import the attached bhp.xml2. Change the SubmitData command configuration to point to local amqp queue3. Place the attached message on submit data ESB queue.4. The records (movement events) are inserted.5. Place the same message again (Can change quantity if required).
Expected:The movement event records are updated.
Actual:Errors
The Movement Path LookUp Service could not find a matching material movement path based on the specified information:MovementPathFullName:MovementDirection:SourceEquipment:DestinationEquipment:SourceMaterialClass:DestinationMaterialClass:SourceMaterial:DestinationMaterial:
Context----------
- We are using the movement lookup feature to submit movement events into Ampla.- These movement events will be coming via an external integration layer.- It gets pretty complex to have the integration layer submit different Location Identifiers, based on source destination equipment, material class, material etc.- Ampla has the movement look up feature that automatically figures which movement item to submit the record to, based on the above fields.- This works for inserts but does not work when it finds a matching record and needs to update it.
I have briefly looked at what is causing it, and I will share it here:
- The SubmitDataHandler correctly finds the matching record (SetId) based on the merge criteria.- But if it is an update it removes the Merge criteria fields from the request.
// If it is an update, get rid of the fields that has been used as a merge criteria. removeFieldsUsedAsMergeCriteria(record);
- As a result when building the merged result movement event specification, the "merge" fields have their Source (SpecValueSource) property as "Stored" rather than "Submitted". - The lookup service ends up searching a movement item based on NULL values.
As a result we are unable to use the movement lookup feature.