Skip to content

Commit

Permalink
We need to remember to update InstanceEvent.InstanceId when creating …
Browse files Browse the repository at this point in the history
…a new instance....
  • Loading branch information
martinothamar committed Dec 6, 2024
1 parent 039bb80 commit b42909b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Altinn.App.Api/Controllers/InstancesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ public async Task<ActionResult<Instance>> Post(

// create the instance
instance = await _instanceClient.CreateInstance(org, app, instanceTemplate);
foreach (var instanceEvent in result.ProcessStateChange?.Events ?? [])
{
instanceEvent.InstanceId = instance.Id;
}
}
catch (Exception exception)
{
Expand Down Expand Up @@ -566,6 +570,10 @@ [FromBody] InstansiationInstance instansiationInstance
}

instance = await _instanceClient.CreateInstance(org, app, instanceTemplate);
foreach (var instanceEvent in processResult.ProcessStateChange?.Events ?? [])
{
instanceEvent.InstanceId = instance.Id;
}

if (isCopyRequest && source is not null)
{
Expand Down Expand Up @@ -683,6 +691,10 @@ [FromRoute] Guid instanceGuid
ProcessChangeResult startResult = await _processEngine.GenerateProcessStartEvents(processStartRequest);

targetInstance = await _instanceClient.CreateInstance(org, app, targetInstance);
foreach (var instanceEvent in startResult.ProcessStateChange?.Events ?? [])
{
instanceEvent.InstanceId = targetInstance.Id;
}

await CopyDataFromSourceInstance(application, targetInstance, sourceInstance);

Expand Down

0 comments on commit b42909b

Please sign in to comment.