Skip to content

Commit

Permalink
Add guide for multi-app-solution
Browse files Browse the repository at this point in the history
  • Loading branch information
standeren committed Aug 24, 2023
1 parent 908a127 commit f351691
Show file tree
Hide file tree
Showing 12 changed files with 606 additions and 0 deletions.
65 changes: 65 additions & 0 deletions content/app/guides/multi-app-solution/_index.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: General approach for making a multi-app solution in Altinn
linktitle: Multi-app solution
description: Considerations and explanations of how to go about when creating a multi-app solution
weight: 250
aliases:

- /app/multi-app-solution/

---

Before continue reading these guidelines, please consider if
a multi-app solution is what you need to fulfill the purpose
of your form(s).

## What is a multi-app solution?

A multi-app solution is a solution consisting of two or more
cooperating apps, where typically (as per now) the "
original" application(s) will trigger a creation of a new
instance of the receiving application. As a part of the
instantiation of the receiving application it is possible
prefill the instance with specific data from the running
instance of the original application.

## Do I need a multi-app solution?

A multi-app solution is in most cases not a necessary
architectural choice for an Altinn form.

### Use cases where you can consider utilize a multi-app solution:

Criteria that should be met if you could consider creating a
multi-app solution:

- My forms will be answered by users that does not have
Altinn
- It is okay that my receiving forms must be deleted in
order to end the lifecycle of the form.
- The receiving form will act as temporary dashboard in
order to view and/or process the incoming forms, since you
dont have any receiving platform that are processing the
forms.

### Alternative solution using eFormidling

It might be that the solution you are looking for is a form,
or multiple forms, that is set up to interact with _
eFormidling_, which is another service offered by
Digitaliseringsdiriktoratet. Read more about
eFormidling [here](../../development/configuration/eformidling/_index.en.md)
. A solution that is integrated with eFormidling can
implement custom code on process-changes by using the
predefined methods i app-backend. Read more about
that [here](../../development/configuration/process/_index.en.md)
. This custom code can build up a
message, with some form-specific content, that can be sent
to some public institution, instead of using
instantiating a second application being the receiving form.
Be aware that Altinn and eFormidling integration has some
limitations in terms of supported message types, which as
per now is limited to DPO and DPF.
Which means that you will not need to follow this guide.

{{<children description="true" />}}
16 changes: 16 additions & 0 deletions content/app/guides/multi-app-solution/_index.nb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: Generell fremgangsmåte for å utvikle en multi-app løsning i Altinn
linktitle: Multi-app løsning
description: Vurderinger som burde gjøres og forklaringer på hvordan å gå frem når man utvikler en multi-app løsning
weight: 250
aliases:

- /app/multi-app-solution/
---

Før du leser videre i denne guiden, vær så snill å gjør en vurdering om en multi-app løsning er det du trenger for å realisere skjemaet ditt.

## Trenger jeg en multi-app løsning?
...

{{<children description="true" />}}
11 changes: 11 additions & 0 deletions content/app/guides/multi-app-solution/considerations/_index.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Considerations you should do before developing a multi-app solution
linktitle: Considerations involving multi-app solution
description: Considerations that should have been made when creating a multi-app solution
weight: 30
aliases:

- /app/multi-app-solution/considerations/

---

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Considerations you should do before developing a multi-app solution
linktitle: Considerations involving multi-app solution
description: Considerations that should have been made when creating a multi-app solution
weight: 30
aliases:
- /app/multi-app-solution/considerations/
---
23 changes: 23 additions & 0 deletions content/app/guides/multi-app-solution/instructions/_index.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: Instructions for making a multi-app solution in Altinn
linktitle: Multi-app solution instructions
description: Explanations of how to go about when creating a general multi-app solution
weight: 20
aliases:

- /app/multi-app-solution/instructions/

---

{{<children description="true" />}}

## General Modifications

In general, there are a few things that one must remember to
do in the process of developing these applications.

1. Remember adding custom services to
the `RegisterCustomAppServices` method in `program.cs`
2. If adding any values as prefill for the new instance of
the receiving application, remember to add them to the
data model of the receiving application
12 changes: 12 additions & 0 deletions content/app/guides/multi-app-solution/instructions/_index.nb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Instructions for making a multi-app solution in Altinn
linktitle: Multi-app solution instructions
description: Explanations of how to go about when creating a general multi-app solution
weight: 20
aliases:

- /app/multi-app-solution/instructions/

---

{{<children description="true" />}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: Receiver Application
linktitle: Multi-app solution instructions
description: Instructions for setting up the receiver application
weight: 20
aliases:

- /app/multi-app-solution/instructions/receiver-app

---

## Getting Data From the Trigger Application

The receiving application needs much less configuration as a
bare minimum receiver application, at least. The main task
for the receiver application is to fetch the data received
from the trigger application(s) and represent them in a way.
This is done by utilising the `ProcessDataRead` method in
the `DataProcessor` service along with the `UpdateData`
method on the `dataClient`. See example code below:

```csharp
public async Task<bool> ProcessDataRead(Instance instance, Guid? dataId, object data)
{
bool edited = false;

if (data.GetType() == typeof(DataModel))
{
DataModel model = (DataModel)data;

DataElement attachments = instance.Data.FirstOrDefault(de => de.DataType == "vedlegg");

if (attachments != null)
{
_logger.LogInformation("// App 2 // Received data");

var instanceGuid = Guid.Parse(instance.Id.Split("/")[1]);

await _dataClient.UpdateData(model, instanceGuid, typeof(DataModel), instance.Org, instance.AppId, int.Parse(instance.InstanceOwner.PartyId), Guid.Parse(instance.Data.Where(de => de.DataType == "datamodel").First().Id));
edited = true;
}
}
return await Task.FromResult(edited);
}
```

## Stopping a Running Instance

Since this receiving application, in most cases, will act as
an on-demand dashboard for collecting data from trigger
apps, the application has no natural way of ending its
process, since it is not sent in as any other normal form.
To bypass this obstacle, the incoming forms should either;

1. be manually deleted after being read, or
2. they must be implemented with a demand of some sort of
user interaction
that will trigger the process to end.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Mottaksapp
linktitle: Multi-app solution instructions
description: Instruksjoner for mottaksappen
weight: 20
aliases:

- /app/multi-app-solution/instructions/receiver-app

---
Loading

0 comments on commit f351691

Please sign in to comment.