<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><div>Hi Guys,</div><div><br></div><div>Wonder if anyone can help.</div><div><br></div><div>I am testing with time of day routing, and I want to be able to check yearly/monthly conditions before weekly conditions are picked up.</div><div><br></div><div>I can do this successfully by just inputting XML into the dialplan, and works as expected, my issue is now when extracting the detail required from a database using lua.</div><div><br></div><div>I for example have 3 entries below for different times of the year;</div><div><br></div><div><br></div><div>+------------+-------+------+----------------+</div><div>| dayofmonth | month | year | dayofmonthtime |</div><div>+------------+-------+------+----------------+</div><div>| 25 | 12 | 0 | 0 |</div><div>| 1 | 1 | 2016 | 540-1050 |</div><div>| 10-18 | 9 | 2015 | 600-840 |</div><div><br></div><div><br></div><div><br></div><div>So when creating directly using xml I get;</div><div><br></div><div>table.insert(xml, [[<condition mon="12" mday="25" break="on-true">]]);</div><div>table.insert(xml, [[<action application="set" data="TOD=sales" inline="true"/>]]);</div><div>table.insert(xml, [[<action application="set" data="Status=closed inline="true"/>]]);</div><div>table.insert(xml, [[</condition>]]);</div><div>table.insert(xml, [[<condition year="2016" mon="1" mday="1" break="on-true">]]);</div><div>table.insert(xml, [[<action application="set" data="TOD=sales" inline="true"/>]]);</div><div>table.insert(xml, [[<action application="set" data="Status=closed inline="true"/>]]);</div><div>table.insert(xml, [[</condition>]]);</div><div>table.insert(xml, [[<condition year="2015" mon="9" mday="10-18" break="on-true">]]);</div><div>table.insert(xml, [[<action application="set" data="TOD=sales" inline="true"/>]]);</div><div>table.insert(xml, [[<action application="set" data="Status=closed inline="true"/>]]);</div><div>table.insert(xml, [[</condition>]]);</div><div><br></div><div><br></div><div><br></div><div><br></div><div>However my issue is when my lua script extracts them, it loops through the 3 entries (each row) , so that only the 3rd entry is available for on-wards routing as it is populating the dialplan 3 seperate times.</div><div><br></div><div>Can someone let me know what Im doing wrong?</div><div><br></div><div>Im just doing a query as;</div><div><br></div><div>local todnew_query = string.format("select * from timeofday_new where todname='sales' and context_name='xx.xx.xx' order by priority")</div><div> assert (dbh:query(todnew_query,function(todresult)</div><div><br></div><div>And using the result with some if statements, I wondered if anyone had any advice on this?</div><div><br></div><div>Thanks</div><div><br></div><div>Jon</div>                                            </div></body>
</html>