We are trying to use workflow to update an XML file. In the XML for our test data, we have a section called Accounts. In that section, we want to add a new account. If we hard code values into the script in the workflow it does everything correctly but puts the hard-coded values into the XML file. If we try to pass tokens from workflow it doesn't seem to do anything. The workflow shows that it ran, all the steps (all three of them) are green and there are no messages.
We are just trying to figure out getting tokens passed to the script correctly. I created an assign token values step that has some hardcoded values and it shows that they are all passing it seems to the script step. The text file that is supposed to have data added to it gets a new modification date in the Windows file system but nothing is added to the file. If we hard code the values into the script, it works like a champ.
Thoughts?
Here is our code:
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports System.Runtime
imports System.IO
Namespace WorkflowActivity.Scripting.Script
'''<summary>
'''Provides one or more methods that can be run when the workflow scripting activity is performed.
'''</summary>
Public Class Script1
Inherits ScriptClass90
'''<summary>
'''This method is run when the activity is performed.
'''</summary>
Protected Overrides Sub Execute()
Dim filePath As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) & "\MVi\Product Demo\demosettings.config"
Dim fileContents As String = File.ReadAllText(filePath)
Dim newAccount As String = " <account>" &
" <vendor>" & GetTokenValue("Vendor").ToString() & "</vendor>" &
" <number>" & GetTokenValue("Account Number").ToString() & "</number>" &
" <first_name>" & GetTokenValue("First Name").ToString() & "</first_name>" &
" <last_name>" & GetTokenValue("Last Name").ToString() & "</last_name>" &
" <address1>" & GetTokenValue("Address").ToString() & "</address1>" &
" <address2>" & "" & "</address2>" &
" <city>" & GetTokenValue("City").ToString() & "</city>" &
" <state>" & GetTokenValue("State").ToString() & "</state>" &
" <zip>" & GetTokenValue("Zip").ToString() & "</zip>" &
" <cell_phone>" & GetTokenValue("Cell Phone").ToString() & "</cell_phone>" &
" <suffixes>" &
" <suffix>" &
" <balance>" & GetTokenValue("Balance").ToString() & "</balance>" &
" <account_type>Share</account_type>" &
" <rate>0</rate>" &
" <suffix>A</suffix>" &
" </suffix>" &
" </suffixes>" &
" </account>"
fileContents = fileContents.Replace(" </accounts>", newAccount & " </accounts>")
File.WriteAllText(filePath, fileContents)
End Sub
End Class
End Namespace