How to update a value using Jelly Script

Akhil Kumar1
Mega Sage

Hi All ,

I have created a Jelly script to update a state field based on some conditions, but i am not able to update the state field using Jelly script

the same code i got worked in background script

<g:evaluate var="userValue" object="true">

  var userValue = new GlideRecord("sys_user");

  userValue.addQuery('sys_id',gs.getUserID());

  userValue.query();

  userValue;

  </g:evaluate>

  <j:if test="${userValue.next()}">

  <g:evaluate var="itcaUser" object="true">

  var itcaUser = new GlideRecord('x_eyfso_it_capabil_itca_user');;

  itcaUser.addQuery('respondent_email_id', '${userValue.getValue('email')}');

  itcaUser.query();

  itcaUser;

  </g:evaluate>

  <j:if test="${itcaUser.next()}">

  <g:evaluate>

  var itcaResponse = new GlideRecord('x_eyfso_it_capabil_itca_surveyresponse');

  itcaResponse.addQuery('assessment_instance_number','${RP.getParameterValue('sysparm_assessable_type')}');

  itcaResponse.query();

  </g:evaluate>

  <j:if test="${itcaResponse.next()}">

  <g:evaluate>

  var itcaAssessment=new GlideRecord('x_eyfso_it_capabil_assessmentinstance');

  itcaAssessment.addQuery('engagement','${itcaResponse.engagement_number}');

  itcaAssessment.addQuery('survey_user','${itcaUser.sys_id}');

  itcaAssessment.addQuery('state','In progress');

  itcaAssessment.query();

  </g:evaluate>

  <j:if test="${itcaAssessment.next()}">

//here i need to update state to completed

  </j:if>

  </j:if>

  </j:if>

  </j:if>

1 ACCEPTED SOLUTION

Hi Goran Lundqvist,



I have solved the issue


the purpose was i need to update a value in table when some changes happend CMS page


i have created a GlideAjax and solved this issue



Thanks for your quick reply always Appreciate it



View solution in original post

4 REPLIES 4

Mihir Mohanta
Kilo Sage

Remove the single quotes in the Jelly variables. Like,


itcaUser.addQuery('respondent_email_id', ${userValue.getValue('email')});



Thanks,


Mihir


Hi Mihir Mohanta ,



Thanks for your reply



that is working fine , the only things is i need to update the status something like below using Jelly script



itcaAssessment.state="Completed";


itcaAssessment.update();


To be honest.. why mix in Jelly... you only use jelly to make a IF-statement on variables from a g:evaluate... Just make everything inside a g:evaluate instead with javascript if-statements instead.



//Göran


Hi Goran Lundqvist,



I have solved the issue


the purpose was i need to update a value in table when some changes happend CMS page


i have created a GlideAjax and solved this issue



Thanks for your quick reply always Appreciate it