具有值的默认标记在收到新值时替换它

时间:2017-03-06 03:41:17

标签: html xml token splunk

目前我面临的问题是需要将我的令牌初始化为任何值1st。但是,当收到新值时,令牌值将会更改。以下是我的代码:

<form>
      <init>
        <set token="CH1_CHW_FLOW">0</set>     
      </init>        
</form>

<search id="header">
<query>index="rtindex" Label="CH1" Order="12" |eval Value=round(Value,3) |stats latest(Value) as Value by ID2 |rename ID2 as Label | untable Label field name | xyseries field Label name</query>
<earliest>@d</earliest>
<latest>now</latest>
<preview>
  <set token="FLOW_LPS">$result.CH1_CHW_FLOW_LPS$</set>
  <set token="FLOW">$result.CH1_CHW_FLOW$</set>
  <set token="COOLING_LOAD">$result.CH1_COOLING_LOAD$</set>
  <set token="EFF">$result.CH1_EFF$</set>
</preview>

<table id="Chiller_1" border="1px solid black"> 
      <tr><th>HEADER Details </th><th>Values</th></tr>
       <tr><td>CHWF (USGPM)</td><td>$CH1_CHW_FLOW$</td></tr> 
       <tr><td>FLOW (LPS)</td><td>$CH1_CHW_FLOW_LPS$</td></tr>
       <tr><td>COOLING LOAD</td><td>$CH1_COOLING_LOAD$</td></tr>  
       <tr><td>KW/Ton</td><td>$CH1_EFF$</td></tr> 
 </table>  

但由于不明原因,我无法将值初始化为零。它告诉我 $ result.CH1_CHW_FLOW $而不是零。请指教。非常感谢你。

1 个答案:

答案 0 :(得分:0)

解决它的方法使用了eval:  如果(ISNULL($ $ result.fieldname),0,$ $ result.fieldname)