Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance BulkDispatchWorkflows Activity with Support for Multiple Input Keys and Customizable Input Key #5182

Merged
merged 4 commits into from
Apr 4, 2024

Conversation

sfmskywalker
Copy link
Member

@sfmskywalker sfmskywalker commented Apr 4, 2024

This PR introduces significant improvements to the BulkDispatchWorkflows activity by enabling the support for multiple input keys. Specifically, it allows users to provide a list of items, with each item being a dictionary. This change permits each dictionary key to act as the input name for the dispatched workflow, providing users with precise control over the inputs of the child workflow.

Furthermore, this update includes the flexibility to configure a different key for the workflow input, moving beyond the previously hardcoded "Item" key. This enhancement ensures backward compatibility for users who prefer not to adopt the "list of dictionaries" method, maintaining the activity's utility in existing workflows without requiring any modifications.

Sample Items JS expression:

return [{
    Order: { 
        id: 1,
        customerId: 1
    }
},
{
    Order: { 
        id: 2,
        customerId: 2
    }
}];

The dispatched workflows will each now receive an input called "Order".

Fixes #5132

The 'PublicAPI' attribute has been added to the ActivityExecutionContext class. This signals that this class is part of our public API and should not be modified in a way that violates backward compatibility. Furthermore, the 'RequiresUnreferencedCode' attributes were removed from the 'CompleteActivityAsync' and 'CompleteActivityWithOutcomesAsync' methods, as these methods no longer need them.
A new merge function has been added to the DictionaryExtensions. This function combines the contents of two dictionaries, prioritizing the keys and values from the second dictionary whenever there is a collision.
The code has been adjusted to include a default input item key in the BulkDispatchWorkflows module. This key will be used for the item input when dispatching workflows, unless the Items field contains a list of dictionaries. Additionally, modifications have been made to convert the item into an input dictionary if it isn't already one and merge this with the input dictionary.
@sfmskywalker sfmskywalker requested review from a team April 4, 2024 13:44
@raymonddenhaan
Copy link
Contributor

Fixes #5132

The commit adds a critical detail about dictionary operation in the method summary. It clearly states that during the merge operation, the value from the 'other' dictionary overwrites the value in the target dictionary when the same key exists in both.
@sfmskywalker sfmskywalker merged commit 31092f8 into main Apr 4, 2024
6 checks passed
@sfmskywalker sfmskywalker deleted the issue/5132 branch April 4, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance BulkDispatchWorkflows to Support Dynamic Input Mapping
2 participants