08-25-2017 12:55 PM - edited 03-14-2019 05:33 PM
I am trying to capture user input in the way of an account number. I would then use that value to look up and match an entry in an XML file to pull the DID number associated to that value. Once I have that information, I can write that to another XML file that is structured in the form of the outbound campaign XML POST for contacts. I can insert one set of values but if someone wants to enter more than one pair (acct, DID) into the file, I have an issue. When I do the XML Keywork Transform, I don't know how many values there will be, plus I want re-use the variables I already have in place.
Here is some more info:
Get Digit String = acct number (7200)
<?xml version="1.0" encoding="ISO-8859-1" ?> <Acct> <7200>9195551212</7200> </Acct>
XMLLookup - returns phone number based on acct number (9195551212)
Now that I have that, I want to write that information into a different XML file that will be used for the body of a REST call to upload contacts to outbound campaign.
Here is my template for the keyword transform:
<?xml version="1.0" encoding="UTF-8"?> <campaignContacts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="campaignContacts.xsd"> <campaign name="Outbound-IVR"> <refURL>https://ccx01.test.local/adminapi/campaign/2</refURL> </campaign> <allowDuplicateContacts>true</allowDuplicateContacts> <csvdata> Account Number, Phone1 %value1%, %value2% </csvdata> </campaignContacts>
The result document should look like this:
<?xml version="1.0" encoding="UTF-8"?> <campaignContacts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="campaignContacts.xsd"> <campaign name="Outbound-IVR"> <refURL>https://ccx01.test.local/adminapi/campaign/2</refURL> </campaign> <allowDuplicateContacts>true</allowDuplicateContacts> <csvdata> Account Number, Phone1 7200, 9195551212 </csvdata> </campaignContacts>
I can get it that far. The issue I have is if I want someone to stay in the script and input multiple acct numbers one after another and each time they loop through the script, I write the acct number/phone number pair to the XML file.
What I want to be able to do is the capture the first user input write it to the file and then ask them if they want to enter another account number and write that information to the same XML file but on the next line like so:
<?xml version="1.0" encoding="UTF-8"?> <campaignContacts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="campaignContacts.xsd"> <campaign name="Outbound-IVR"> <refURL>https://ccx01.test.local/adminapi/campaign/2</refURL> </campaign> <allowDuplicateContacts>true</allowDuplicateContacts> <csvdata> Account Number, Phone1 7200, 9195551212 7201, 8885551212 7202, 7775551212 </csvdata> </campaignContacts>
When I do a XML look up on that particular results doc, I can pull the data in <csvdata> and put that into an array. The result looks like this:
U"\nAccount Number, Phone1\n7200, 9195551212\n7201, 8885551212\n7202, 7775551212"
I then split on "\n" and can substring it for the two values of account number and phone number.
I just wonder how to write multiple values into an XML file under the same tag.
Thanks
08-28-2017 09:00 PM
This seems like a very cool adventure, and much respect to you for getting this far.
Simple question: Why not just submit the XML payload in separate API calls: one for each entry from the caller? Why do they all need to be in the same XML payload?
08-29-2017 05:40 AM
Actually, I didn't think about that. I assumed the REST call to the upload the contacts would need to have all the contacts present since it activates the campaign on upload. I guess I could see if uploading one acctnumber/DID pair at a time would work and when they are ready, just send another REST call to activate the campaign. I will test that out today and let you know.
I looked at this more last evening and I was trying out some scripts that take data within two variables and tried adding that to an array. The issue I had with that is when I incremented the index it and started the loop again, I kept just putting new data in the next index and lost the data in the prior index.
Start Loop: Set sStoreNumber = iStoreNumber example value - (1000) Set sStoreDID = iStoreDID example value - (5000) Increment iStoreNumber Increment iStoreDID Do sXMLArray = new String[10] Set sXMLArray[iArrayIndex] = sStoreNumber+sStoreDID Increment iArrayIndex Goto Loop End
08-29-2017 09:00 AM
Do sXMLArray = new String[10]
You're creating a new Array each loop, therefore, destroying the previous array and its data. You should just make the variable in the variable pane for sXMLArray = new String[10].
08-29-2017 10:23 AM
Yep, that makes sense. Now it looks like this. I will now see if I can print out the array into the document. From what I can see about the campaign, I have it set to active all the time so when it sees new contacts uploaded it triggers the campaign. I need to disable it and then see about the REST call to enable it after the contacts have been uploaded.
Start Loop: Set sStoreNumber = iStoreNumber Set sStoreDID = iStoreDID Increment iStoreNumber Increment iStoreDID If (iArrayIndex == sXMLArray.length ) Then True Goto End False Set sXMLArray[iArrayIndex] = sStoreNumber+sStoreDID Increment iArrayIndex Goto Loop End: End
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide