In reply to: Maximilian H.
Hi Daniel,
thank you very much for your answer.
I uploaded my example in the attachment.
Yes I read in the file about the attachment, then I have choice field where I choose the file.
Then I trigger my action and give everything into the C#-code.
In the C#-code I want to work with the ID of the selected file.
Your code snippet:
var attachment = args.Context.CurrentDocument.Attachments.FirstOrDefault(x=>x.ID = 123)
was read only property with the ID.
I hope that this declaration can help you a little bit more.
Thank you very much and best regards
Maximilian
Hi Maximilian,
yes it was a simple snippet. A more elaborate one would be:
SQL Query of the choice field:
SELECT [ATT_ID] as Id, ATT_Name as Label
FROM [dbo].[WFDataAttachmets]
where ATT_WFDID = {WFD_ID}
and [ATT_IsDeleted] = 0
and [ATT_FileType] = '.xlsx'
Code:
var idOfchoiceField = GetFromConfiguration
var choiceFieldValueId = args.Context.CurrentDocument.ChooseFields.FirstOrDefault(x=>x.ID == idOfchoiceField ).Value.ID
var attachment = args.Context.CurrentDocument.Attachments.FirstOrDefault(x=>x.ID == choiceFieldValueId)
Of course, there could be an issue, when the attachment hasn't been saved before. You could add the attachment in step 1 and select the field value in step 2 after which follows you action. But this is only a guess.
Best regards,
Daniel