Anhänge nach Datentyp in PowerApps einschränken
Eine immer wieder auftauchende Anfrage bei digitalen Prozessen ist die Beschränkbarkeit von Anhangsdokumenten. Bei der Bewerbung sollen beispielsweise nur PDFs angehängt werden können; das IT-Ticket darf nur mit Bildern ergänzt werden.
Das “Attachments”-Steuerelement in PowerApps-Formularen bringt (Stand: Oktober 2019) leider keine Filterung für Datentypen mit. Doch glücklicherweise lässt sich diese Funktionalität relativ unkompliziert mit weniger kleinen Formeln nachbauen.
Zwischenablage erstellen
Als erstes benötigen wir eine Zwischenablage für die Validierung. Dazu erzeugen wir einen neuen Screen und fügen dort ein Label ein.
Der zusätzliche Screen ist nicht zwingend notwendig, aber so hat das Label einen ordentlichen Platz, an dem es nicht stört.
Für den Text-Wert des Labels fügen wir jetzt folgende Funktion ein:
Concat(DataCardValueXX.Attachments.Name,
If(
Or(
Lower(Right(Name,Len(Name)-Find(“.”,Name)))=”pdf”,
Lower(Right(Name,Len(Name)-Find(“.”,Name)))=”doc”,
Lower(Right(Name,Len(Name)-Find(“.”,Name)))=”docx”
),
“1”,”0″))
DataCardValueXX wird durch den Namen des Attachment-Steuerelements ersetzt – Wichtig: NICHT der Name der DataCard selbst, sondern der Name des Attachment-Steuerelements in der DataCard.
Erklärung zur Funktion
Die Funktion liest alle angefügten Dateinamen, extrahiert die Endungen und fügt für erlaubte Endungen eine “1” und für nicht erlaubte Endungen eine “0” an.
- Concat
- Baut eine Zeichenkette aus einer Sammlung von Werten zusammen. In diesem Falle ist die Sammlung der Werte die Eigenschaft “Attachments.Name” unseres Attachment-Steuerelements.
- Or-Block
- Für jeden erlaubten Datentyp gibt es eine Abfrage im “Or”-Block.
- Right(Name,Len(Name)-Find(“.”,Name))
- Mit Hilfe der “Right”- und “Len”-Funktionen wird der Text nach dem “.” im jeweiligen Datennamen, also die Dateiendung, extrahiert.
- Lower([…])=”pdf”
- Die “Lower”-Funktion wird verwendet, um die Dateiendung in Kleinbuchstaben zu erhalten. Da Textabgleiche in PowerApps case-sensitive sind, sparen wir uns so die Abfrage der Dateitypen in mehreren Schreibweisen.
Abfrage beim Senden des Formulars
Wenn alles funktioniert hat, zeigt das Label jetzt einen Binärwert, der anzeigt, ob sich ungültige Dateitypen unter den Anhängen befinden. Auf diesen Wert können wir jetzt beim Abschicken des Formulars prüfen.
In meinem Beispiel wird das Formular – wie i.d.R. üblich – über einen Button abgeschickt. Die “OnSelect”-Funktion des Buttons wird jetzt wie folgt ergänzt:
If(
IsMatch(lbl_attachmentValidation.Text,”0″,Contains),
Notify(“Ungültiger Datentyp angehängt.”,NotificationType.Error),
[… BISHERIGE FUNKTION …]
)
Erklärung zur Funktion
Wie beschrieben, prüft die Funktion auf 0-Werte innerhalb unseres Validierungstextes. Sind 0-Werte vorhanden, wird ein Fehler ausgegeben. Sind keine vorhanden, wird die bereits bestehende Funktion des Buttons – in diesem Fall “SubmitForm()” – ausgeführt.
- IsMatch
- Prüft, ob es eine Übereinstimmung mit einem regulären Ausdruck im Text gibt. In diesem Fall ist der reguläre Ausdruck einfach “0”. Wichtig ist hier die zusätzliche Angabe der Option “Contains”, da “IsMatch” sonst den vollständigen Text vergleichen würde.
- Notify
- Gibt eine Meldung aus. Der NotificationType bestimmt die Farbe und das Icon der Meldung. Die Funktion lässt sich wohl als White- als auch als Black-List nutzen. Dafür einfach auf “1” statt auf “0” prüfen lassen.
Fazit
Die Prüfung auf verschiedene Datentypen im Anhang von PowerApps-Formularen lässt sich relativ unproblematisch hinzufügen und nachträglich anpassen. Durch das Label auf dem gesonderten Screen gibt es darüber hinaus eine einfache Möglichkeit die Funktion zu testen und nachzuvollziehen.
Es ist auch möglich, die Funktionen so anzupassen, dass der Ergebnistext die unerlaubten Dateinamen enthält. Diese können dann z.B. in der Meldung ausgegeben werden.
Viel Spaß beim Ausprobieren.

SharePoint und Informationsarchitektur – worauf kommt es an?

Hat Ihr Unternehmen einen Informations-Lebenszyklus?

Farben zur Optimierung des SharePoint-Kalender

Multi Factor Authentication (Azure und SharePoint)

Qualitätsmanagement - Dokumentation verwalten mit SharePoint

Warum ist Inline-CSS und JavaScript-Code so schlecht?

Dateizugriffsrechte verwalten mit Microsoft RMS – Teil 1

Change Management in IT-Projekten

Dateizugriffsrechte verwalten mit Microsoft RMS – Teil 2

Dateizugriffsrechte verwalten mit Microsoft RMS – Teil 3

Dateizugriffsrechte verwalten mit Microsoft RMS – Teil 4

CQRS in ASP.Net MVC mit Entity Framework

Gefilterte Ansicht über Unterschiede in mehreren Spalten

Vorgesetzte in Nintex per LDAP-Abfrage ermitteln

Migration IBM Lotus Notes zu Microsoft SharePoint

Fünf Tipps für eine verbesserte Software-Adoption

Produktiver lernen mit SharePoint

Fünf Tipps für mehr SharePoint-Adoption in Unternehmen

Was kann der neue Office 365 Planner – und was kann er nicht

Xamarin – plattformübergreifende App-Entwicklung

Braucht man wirklich jQuery?

Was ist Application Lifecycle Management (ALM)?

Corporate News – Das zentrale Medium interner Kommunikation

SharePoint vs. TYPO3 – Sechs Gründe für SharePoint-Intranet

Handlebars.js – Semantische Template Library

Der wiederholte Bereich in Nintex Forms

Grundlagen der Datenmodellierung

Angular 5 Custom Filter in Angular Material Data-Table

Struktureller Aufbau eines Angular Modules

Spaltenformatierung in SharePoint: Column formatting vs. JS

Angular Route-Guards

Nutzung der SharePoint REST API mit Microsoft Flow

Zentralisiertes Logging – Simpler Logging-Stack mit Graylog

Grundlagen der Gestaltung

SharePoint Framework Client-Side Webparts mit React

Tipps und Tricks mit Entity Framework

Ich bin im Flow! – Eine Übersicht zu Microsoft Flow

Teams Extensions – Erstellen von Erweiterungen für Teams

Die Bedeutung einer Governance

Drei Tipps für mehr SharePoint-Begeisterung

GraphQL – Die Alternative zu REST

Anhänge nach Datentyp in PowerApps einschränken

Testen von Angular Anwendungen mit Cypress

PDF-Konverter in Power Automate

Umfragen in Teams mit Microsoft Forms

Microsoft Teams: mehr als Videotelefonie und Chat

Was Sie beim nächsten IT-Projekt beachten sollten

Ohne Programmierkenntnisse zum Entwickler werden

Die Awareness kommt mit dem ersten Cyberangriff
Erfahren Sie mehr

Ich bin im Flow! – Eine Übersicht zu Microsoft Flow

PDF-Konverter in Power Automate

Power Platform Übersicht

SIGA: Mehrsprachige Zusammenarbeit per Microsoft 365

Bell Food: Optimierte Produktverkostung per Power Platform

PUMA: Plattform für Low-Code/No-Code-Lösungen

Kissling + Zbinden: Zentrales Arbeiten in «Projektraum 365»

Toyota: Automatisiere HR-Prozesse mit der Power Platform

HOCHDORF: Mit Power in die Automatisierung von Produktdaten

FIVE: Prozess-Automation auch für KMUs

Landqart: Mit M365 zum Modern Workplace

WENKO: Auftragsvorgänge effizient mit Power Apps managen

Verkehrsbetriebe Luzern: Power-Platform-Dokumentverwaltung

Bertelsmann: novaAudit PowerCloud Edition

GraphQL – Die Alternative zu REST

Microsoft MVP Auszeichnung für Enea Liçaj

Microsoft Power Platform: Beratung zur Einführung

novaCapta Design Editor für App Design

Der wiederholte Bereich in Nintex Forms

Spaltenformatierung in SharePoint: Column formatting vs. JS

Tipps und Tricks mit Entity Framework

Multi Factor Authentication (Azure und SharePoint)

Xamarin – plattformübergreifende App-Entwicklung

Migration IBM Lotus Notes zu Microsoft SharePoint

Umfragen in Teams mit Microsoft Forms

Produktiver lernen mit SharePoint

Dateizugriffsrechte verwalten mit Microsoft RMS – Teil 1

Dateizugriffsrechte verwalten mit Microsoft RMS – Teil 2

Zentralisiertes Logging – Simpler Logging-Stack mit Graylog

Nutzung der SharePoint REST API mit Microsoft Flow

SharePoint Framework Client-Side Webparts mit React

Grundlagen der Datenmodellierung

Hat Ihr Unternehmen einen Informations-Lebenszyklus?

Teams Extensions – Erstellen von Erweiterungen für Teams

Farben zur Optimierung des SharePoint-Kalender

Struktureller Aufbau eines Angular Modules

Grundlagen der Gestaltung

Was kann der neue Office 365 Planner – und was kann er nicht

CQRS in ASP.Net MVC mit Entity Framework

Braucht man wirklich jQuery?

Warum ist Inline-CSS und JavaScript-Code so schlecht?

Testen von Angular Anwendungen mit Cypress

Angular 5 Custom Filter in Angular Material Data-Table

Corporate News – Das zentrale Medium interner Kommunikation

Ohne Programmierkenntnisse zum Entwickler werden

Dateizugriffsrechte verwalten mit Microsoft RMS – Teil 3

Vorgesetzte in Nintex per LDAP-Abfrage ermitteln

Qualitätsmanagement - Dokumentation verwalten mit SharePoint

Die Bedeutung einer Governance

Angular Route-Guards

Digitalisierung der Leistungsabrechnung

SharePoint vs. TYPO3 – Sechs Gründe für SharePoint-Intranet

Was Sie beim nächsten IT-Projekt beachten sollten

SharePoint und Informationsarchitektur – worauf kommt es an?

Fünf Tipps für mehr SharePoint-Adoption in Unternehmen

Fünf Tipps für eine verbesserte Software-Adoption

Drei Tipps für mehr SharePoint-Begeisterung

Change Management in IT-Projekten

Gefilterte Ansicht über Unterschiede in mehreren Spalten

Dateizugriffsrechte verwalten mit Microsoft RMS – Teil 4

Handlebars.js – Semantische Template Library

Was ist Application Lifecycle Management (ALM)?

Microsoft Teams: mehr als Videotelefonie und Chat

Die Awareness kommt mit dem ersten Cyberangriff

Optimiertes Qualitätsmanagement für R+V Versicher

FinOps Microsoft – Microsoft Cloud Kostenoptimierung

FinOps Consulting

FinOps – Was ist das?

Workshop: Paginated Reports in a Day

Wer benötigt ein Intranet?

Was Sie von Copilot erwarten können – und was nicht

Copilot Studio: Was kann das KI-Tool?

Endpoint Management & Security mit Intune

Best Practices für Copilot for Microsoft 365

NIS2 kommt: So bereiten Sie sich optimal vor

Modern Workplace: Erste Schritte zum modernen Arbeitsplatz

Mit Microsoft Copilot in die Zukunft des Arbeitens

Valo ist neuer Partner der novaCapta für Intranets
