title: kusto query language -passing parameter value to user defined function
body: <p>I am trying to send the output from table recordtime value to Function1  as a parameter value. but i am getting below error for <code>Function1()</code></p>
  
  <blockquote>
    <p>semantic error: SEM0100: 'toscalar' operator: Failed to resolve scalar expression named 'recordtime'. </p>
  </blockquote>
  
  <p>I tried with recordtime as passing as <code>tostring()</code> and <code>todatetime()</code></p>
  
  <pre><code>Function definitions:
  Function1(fromdate string,recordtime string)
  Function2(fromdate string,enddatetime string)
  Main (startdate,enddatetime,id)
  
  Function Main (startdate,enddatetime,id){
      TestTable 
      | where (fromdate &gt;= datetime(startdate)
      and todate &lt;= datetime(enddatetime))
      and deviceid == id
      | summarize cnt = count(), recordtime = Timestamp
      | extend getdates = case (
                                cnt == 1,toscalar(Function1(startdate,recordtime)),
                                cnt == 2,toscalar(Function2(startdate,enddatetime )),
                               "Out of range"
                               )
      | Project getdates 
  }
  </code></pre>
  
  <pre><code>Function1 and Function2 returns single array like ([{"fromdate":"2020-03-11T16:39:47.6730000Z"},{"todate":"2020-03-11T16:44:23.8800000Z"}]
  </code></pre>
  
  <p>any suggestions,
  Thanks in advance</p>