I want to replace “isProcessed” to ‘true’ after file is processed. How can I search the filename “3 way check INV.pdf” and replace isProcessed to true for that particular array element only?
This is my code in InvokeCode activity:
If (Not String.IsNullOrWhiteSpace(emailDataStr)) Then
emailInvoiceData = JsonConvert.DeserializeObject(Of JObject)(emailDataStr)
End If
’ Check for AttachmentsList JArray exists
If ((emailInvoiceData(“AttachmentsList”) IsNot Nothing) AndAlso (emailInvoiceData(“AttachmentsList”).Value(Of JArray).Count > 0)) Then
emailInvoiceData(“AttachmentsList”).Value(Of JArray).Item(“3 way check INV.pdf”).Replace(TransactionData)
’ Rewrite file
File.WriteAllText(Path.Combine(Path.GetFullPath(Config(“InputInvoiceDir”).ToString), Config(“EmailInvoiceDataFileName”).ToString), emailInvoiceData.ToString)
End If
My Json file has array:
{
“AttachmentsList”: [
{
“fileName”: “test-asia-trade.zip;3 way check INV.pdf”,
“emailDate”: “Tue, 01 Jun”,
“emailFrom”: “noreply@noreply.cloud”,
“emailSubject”: “New Invoice document is received”,
“emailBody”: “test”,
“isProcessed”: false
}
]
}
@ppr it worked perfectly. Thanks a lot.
Just a question on write text, by using write text activity - it is overwriting whole file rather than just updating one particular array element.
As I have multiple elements in the array, may I know how to modify only value of particular file name?
Serializing elements also won’t work as other array elements are removed from the file.
write text will dump out the entire data in one rush. There will not be a selective update.
Putting the activity after the for each will avoid to write back part results.
Perfect, just do your final testing and mark the solving post as solution. Others will benefit from it. Thanks