VoxCommando
Help and Support (Using VoxCommando) => Command Builder Reference => Topic started by: gavimobile on November 01, 2018, 05:13:22 PM
-
excuse me if this is not the right category.
what would be a simple example for checking if a value or phrase exists first within a xml payload.
if it does exist don't add to payload
if it does NOT exist, add to xml payload.
im breaking my head with this for a few days already.
any assistance is appreciated
-
There are a few unknowns in your question so I'll have to make some assumptions to answer this.
First assumption: You are talking about adding rows to a payloadXML file using actions of the form payloadXML.*
Second assumption: Check if a value exists. Checking for a phrase could be done too but slightly differrently and it could be more complicated because of the possibility of multiple comma separated phrases for a single value.
Basically you can use PayloadXML.GetPhrase to check if a value already exists. Then in a logic block use LastActionSuccess. If true then you don't need to add it because it's already there. Else add the new value/phrase pair.
Very simple example:
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.4.3-->
<command id="1224" name="payloadxml tests" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
<action>
<cmdType>PayloadXML.GetPhrase</cmdType>
<params>
<param>test.xml</param>
<param>2</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<if ifBlockDisabled="False" ifNot="False">
<ifType>LastActionSuccess</ifType>
<ifParams>&&</ifParams>
<then>
<action>
<cmdType>VcAdvanced.Log</cmdType>
<params>
<param>value already exists in payloadXML file</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</then>
<else>
<action>
<cmdType>PayloadXML.AddPair</cmdType>
<params>
<param>test.xml</param>
<param>2</param>
<param>two</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</else>
</if>
</command>
-
thanks, this was exactly what I needed.