如何使用果冻脚本读取对象数组?

问题描述 投票:0回答:1

我试图使用果冻脚本从一个对象的数组中读取值但不能这样做。在脚本之后,我试图读取值但它不起作用。

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="jelly:core" xmlns:g2="glide">
	<style>
		tr.buttons{height:10px;}
	</style>
<g:ui_form>
  <g:evaluate var="jvar_short_text" expression="RP.getWindowProperties().short_text" />
  <g:evaluate
			  var="jvar_bot_param"
			  object="true"
			  expression="RP.getWindowProperties().bot_param" />
   <table width="100%">
		 <j:forEach items="${jvar_bot_param}" var="jvar_param" indexVar="i">
			 <p>${jvar_bot_param}</p>
			 <g:evaluate jelly="true" object="true">
				 var botparam = jelly.jvar_param[i].label;
				 var botName  = jelly.jvar_param[i].name;
			 </g:evaluate>
			 <p>${botparam}</p>
			 <p>${botName}</p>
		 </j:forEach>
     <tr id="dialog_buttons" class="buttons">
        <td colspan="2" align="right">
           <g:dialog_buttons_ok_cancel ok='return validateComments(${jvar_bot_param})' ok_type="button" cancel_type="button" />
        </td>
     </tr>
  </table>
</g:ui_form>
</j:jelly>
Var jvar_bot_param has the following data:

[{
"name": "incident_sysid",
"label": "Incident sysid",
"type": "text",
"default": "859245f94ffe7e80c5a3c3818110c7fc"
}]

Can someone please look into my code and suggest me how to retrieve the data from array.
arrays servicenow jelly
1个回答
0
投票

试试这个,应该工作:

<j2:forEach items="$[jvar_bot_param]" indexVar='i'>
    <g2:evaluate>
        var idx = parseInt("$[i]");
        var botparam = jvar_bot_param[idx].label;
        var botName = jvar_bot_param[idx].name;
    </g2:evaluate>
    <p>$[botparam]</p>
    <p>$[botName]</p>
</j2:forEach>
© www.soinside.com 2019 - 2024. All rights reserved.