Aug 12 2023 09:22 AM
I have created a flow in Power Apps. The flow stores attachments received in a shared mailbox in a List.
The list contains a choice-field that I would like to assign a calculated value to.
Flow
- Get Attachment (V2) (emails sent to shared account)
- Initialize variable 'fname' as String
- Apply to each Attachments
- Get Attachment (V2)
- Set fname variable to outputs('Get_Attachment_(V2)')?[body/name']
- Condition items('Apply_to_each')?['isInline'] is not equel to true
- If yes:
- Create item in Sharepoint list (Title: fname)
- Add the attachment to the newly created List Item.
This part works.
But I am unable to understand how to set the value of a choice-field based on a formula.
In this case I want to assign the value based on the attachment filename, i.e
'SPS*' -> ChoiceA,
'*TA* -> ChoiceB,
'*.xlxs' => ChoiceC,
etc.
(ambiguities in rules is not a practical issue)
Any help would be much appreciated. I'm new to Sharepoint but can code.
Aug 13 2023 09:36 AM - edited Aug 13 2023 09:37 AM
Hi @jlarsen01
go to your field in the "Create Item in SharePoint" action and select "Enter custom value"
Go to the "Expression" tab, enter the following formula and press update
if(
equals(
indexOf(variables('fname'),'SPS'),
0),
'ChoiceA',
if(
greater(
indexOf(variables('fname'),'TA'),
-1),
'ChoiceB',
if(
endsWith(
variables('fname'),
'.xlxs'
),
'ChoiceC',
'Nothingmatches'
)
)
)
Best Regards,
Sven