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

FormLocationKey ArgumentNullException #14936

Merged
merged 3 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,16 @@ public override IEnumerable<Outcome> GetPossibleOutcomes(WorkflowExecutionContex

public string FormLocationKey
{
get => GetProperty<string>();
set => SetProperty(value);
get => GetProperty(() => string.Empty);
set => SetProperty(value ?? string.Empty);
}

public override Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext)
{
if (workflowContext.Output.TryGetValue(WorkflowConstants.HttpFormLocationOutputKeyName, out var obj)
&& obj is Dictionary<string, string> formLocations)
{
// if no custom location-key was provided, we use empty string as the default key.
var location = FormLocationKey ?? string.Empty;

if (formLocations.TryGetValue(location, out var path))
if (formLocations.TryGetValue(FormLocationKey, out var path))
{
_httpContextAccessor.HttpContext.Items[WorkflowConstants.FormOriginatedLocationItemsKey] = path;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
<label asp-for="FormLocationKey" class="form-label">@T["Form Location Key"]</label>
<input type="text" asp-for="FormLocationKey" class="form-control" />
<span asp-validation-for="FormLocationKey"></span>
<span class="hint">@T["This value needs to correspond with the Form Location Key value utilized in the HTTP request event settings. Leave blank if the workflow handles a single form event."]</span>
<span class="hint">@T["This key name should be equal to the 'Form Location Key' of the HTTP request event. Leave blank if the workflow only handles a single form."]</span>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public int TokenLifeSpan

public string FormLocationKey
{
get => GetProperty<string>();
set => SetProperty(value);
get => GetProperty(() => string.Empty);
set => SetProperty(value ?? string.Empty);
}

public override bool CanExecute(WorkflowExecutionContext workflowContext, ActivityContext activityContext)
Expand All @@ -77,13 +77,10 @@ public override Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecutionCont
if (!workflowContext.Output.TryGetValue(WorkflowConstants.HttpFormLocationOutputKeyName, out var obj)
|| obj is not Dictionary<string, string> formLocation)
{
formLocation = new Dictionary<string, string>();
formLocation = [];
}

// if no custom location-key was provided, we use empty string as the default key.
var location = FormLocationKey ?? string.Empty;

formLocation[location] = GetLocationUrl(value);
formLocation[FormLocationKey] = GetLocationUrl(value);

workflowContext.Output[WorkflowConstants.HttpFormLocationOutputKeyName] = formLocation;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@


<div class="mb-3" asp-validation-class-for="FormLocationKey">
<label asp-for="FormLocationKey" class="form-label">@T["Form Location"]</label>
<label asp-for="FormLocationKey" class="form-label">@T["Form Location Key"]</label>
<input type="text" asp-for="FormLocationKey" class="form-control" />
<span asp-validation-for="FormLocationKey"></span>
<span class="hint">@T["This key serves to differentiate the current form's location. Leave blank if the workflow handles a single form event."]</span>
<span class="hint">@T["This key name is used to store and then retrieve the current form's location. Leave blank if the workflow doesn't handle any form or a single one."]</span>
</div>

<script depends-on="jQuery" asp-src="~/OrchardCore.Workflows/Scripts/orchard.http-request-event-editor.min.js" debug-src="~/OrchardCore.Workflows/Scripts/orchard.http-request-event-editor.js" at="Foot"></script>
Expand Down