This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
I am working on a proof of concept to update the configuration of tools using the Update RAW XML with Formula action type from within the action tool and running into problems with using the replace function to locate the existing XML and replace it with my desired XML.
I have created a batch macro with 2 control parameters (Find and Replace). Those control parameters feed into a single Action tool that is using the Update Raw XML with Formula action type, and attempting to update the inner XML for the Input Data tool.
This works when I Find/Replace a single value like the file name
Or a single unquoted attribute like Field Length
However when I try to find a longer string that that includes both the tag and an attribute within the tag, like in this example where I am changing both the record limit and the input file name (note the string was copied directly from the macro's XML opened in Notepad ++)
Alteryx appears not to find the string and so the configuration for the input in the macro is not modified. This feels like an issue with the syntax that is being searched for but I have no idea how to determine what the correct syntax should be. Anyone run into this before or have suggestions on how to find and replace large
So with the underlying XML as seen in notepad ++ as:
When I find/replace looking for RecordLimit="" it works
But when I look for File RecordLimit="" it does not work
To get even more specific it works with a single space before record limit ' RecordLimit=""'
But does not work with the "e" from "File" and the space e RecordLimit=""
So I am guessing that maybe there is another character that needs to go around the attribute names found inside of an XML tag (forgive me if I am not using correct nomenclature as I am not an XML person) any suggestions?
Hi @bkclaw113 I think the issue here is whether the values in your find/replace have quotes in them. as these could (for want of a better word) break the Replace() function, by terminating the string early. You could try wrapping the control parameter in single quotes, assuming they will never appear in the string, if the string could have a combination of double and single quotes, then it might get a bit tricky...
@bkclaw113 just continuing on that thought, I'd always recommend using the test view in the interface designer so you can see the interface values, or use debug mode to see what is actually going on with the problem values.
You mentioned viewing the XML in Notepad++. Did you know you can view the XML for each tool in Alteryx, by changing the user setting "Display XML in Properties Window"?
Are you just trying to change the path to your CSV file? In your second screenshot, in the section "XML Element to Update", you have the first line highlighted in blue. If you instead highlight the line for "File - value = D:\A;teryx....", you should be able to easily update the path to the CSV. In that "XML Element to Update" section, the macro will update whichever line you have highlighted in blue.
And like @OllieClarke mentioned, in the Interface Designer window, the Test View button (magic wand) and the Debug button are a huge help.
@ChrisTX, yes I did know about viewing teh XML from within Alteryx, I just prefer using notepad++ as it is easier to copy into and out of and keep notes as I am trying different approaches.
Also the selection of the entire Input, verses the File tag is intentional as I this is just a POC and I ultimately want/need to be able to change any of the tags, so my find/replace needs to act on the entire configuration tag, not just a single child element.
@OllieClarke since the values that I am using in the Find and Replace control parameters are being passed by value as strings, I am not including any (single or double) quotes in the strings, however I did manual testing and did use single quotes to wrap the strings which only contained double quotes and I still experienced the same issue. Also over the course of testing I did pass values that included double quotes and it worked:
Works without issue, so I do not believe it is the quotes
I am using the interface view and debug mode, as I agree they are terrific tools under normal circumstances to understand odd behavior like this, however in this case, particularly with using the replace function it either finds the search string and performs the replace, or it does not find it and nothing changes. Please let me know if there is something else that I am missing, but I don't think the answer lies in debug mode.
Just to add some more to this investigation, I took the simple piece that was working:
Then I used the generate rows to add every possible character from ascii 1 to 256 in front of each string. The only character that resulted in the replace being executed (and returning only a single row of data) was char(32) which is <space>. I then repeated the process to see if any character prior to the space would work and char(109) (lower case m) worked, which from viewing the raw XML (in either Alteryx or notepadd++) does not appear anywhere. Having success finding that 'm RecordLimit=""' worked as the search string I tried the generate rows again and no character before the 'm' caused the Find value to be found, so I am again at a loss for what to try next.
Hey @bkclaw113 I've been having a play with this. I found that it was the chevrons which were causing the problem.
and replacing with
works fine, but it doesn't work when you include the < before File.
Luckily if you change your action tool to 'Update Outer XML', then I think that solves the issue. This means that you're including the xml tags in your replace function (more so in the find part), and so they will be updated.