How to use jelly variable in javascript / glide?

Deepak Ingale1
Mega Sage

Hello All,

I am building one page for room booking application.

What I am trying to do is to find the available rooms when user selects 'requested from' and 'requested till' fields (both are glide datetime).

I am passing these fields using getWindowProperties() function to variable "jvar_my_variable" as seen below. It is highlighted in bold.

What is happening is that, When I use this variable in the g:evaluate tag which is also highlighted, I see that this variable contains null value rather than actual datetime value. I have also attached the screenshot for reference.

Can any 1 help me in troubleshooting this issue why I am not able to see actual date time and seeing at null value?

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<head>

<style>

#myIdDiv{

  width:800px;

  margin:50px;

}

#mydoc{

  margin:50px auto;

  width:100px;

}

#mydiv{

  background:maroon;

  color:white;

  height:20px;

  text-align:center;

}

#mytable{

  border-collapse:collapse;

  border:1px solid black;

  width:100%;

}

#mydata, #myrow{

  width:auto;

  border-collapse:collapse;

  border:1px solid black;

  text-align:center;

}

</style>

</head>

<div id="myIdDiv">

<div id="mydiv">Welcome to Status Checker</div>

  <g:ui_form>

  <!-- Get values from dialog preferences passed in -->

    <g:evaluate var="jvar_my_variable"

    expression="RP.getWindowProperties().get('my_variable')" />

  </g:ui_form>

  <g:evaluate>

    var gr = new GlideRecord('u_book_room');

    gr.addQuery('status','Booked');

    gr.orderBy('u_room');

    gr.query();

  </g:evaluate>

  <table id="mytable">

    <th id="header1" colspan="6">Room Status</th>

    <tr id="myrow">

    <td id="mydata">Request Number</td>

    <td id="mydata">Room Number</td>

    <td id="mydata">Status</td>

    <td id="mydata">Requested From</td>

    <td id="mydata">Requested Till</td>

    <td id="mydata">Current Record Time</td>

    </tr>

    <j:while test="${gr.next()}">

      <g:evaluate   jelly="true">

        var diffStart = gs.dateDiff(gr.getDisplayValue('u_requested_from'), jelly.jvar_my_variable,true);

        gs.addInfoMessage(gr.getDisplayValue('u_requested_from') + " " +   jelly.jvar_my_variable);

        gs.addInfoMessage('Hello ' + diffStart);

      </g:evaluate>

      <j:if test="${diffStart &gt; 0}">

        <tr id="myrow">

        <td id="mydata"><a href="u_book_room.do?sys_id=${gr.getDisplayValue('sys_id')}">${gr.getDisplayValue('u_number')}</a></td>

        <td id="mydata">${gr.getDisplayValue('u_room')}</td>

        <td id="mydata">${gr.getDisplayValue('u_status')}</td>

        <td id="mydata">${gr.getDisplayValue('u_requested_from')}</td>

        <td id="mydata">${gr.getDisplayValue('u_requested_till')}</td>

        <td id="mydata"> ${jvar_my_variable} </td>

        </tr>

      </j:if>

    </j:while>

  </table>

</div>

</j:jelly>

7 REPLIES 7

Now its working right?



Yes, It is working fine now


ok