How to use a variable in an if statement in g:evaluate in jelly

MooseBeast
Tera Contributor

Hi - apologies but I am fairly new to jelly, ServiceNow etc

I am trying to use a radio button to either show all records or only those where i am the owner.  I am using local storage to preserve the selection when the page reloads 

Everything is fine including the admin test but i cant get following if statement to xeute - it just ignores it and applies the addQuery anyway - thanks in advance

  if (sMode ='Me') // this isnt executing ***
            gr.addQuery('u_owner',sUserID);
<script>
var sMode = localStorage.getItem("sModeKey");
document.getElementById(sMode).checked = true; // check the displayed option
buildJourneys();


function buildJourneys(){
<g:evaluate var="jvar_journey" object="true" jelly="true">
  // load the journeys
  // ** NEED to only include those the user is allowed to access **

    var objs = [];  
    var sCompanyID = ''+gs.getUser().getCompanyID();
    var sUserID = gs.getUserID();
    var sUserName = gs.getUserName();


    var gr= new GlideRecord('x_ka2_cozpro_journey');
    if (!gs.hasRole('admin'))
        gr.addQuery('u_company',sCompanyID);
    if (sMode ='Me') // this isnt executing ***
            gr.addQuery('u_owner',sUserID);
    gr.orderBy('journey_name');
    gr.query();
    while(gr.next()){
        objs.push({'sys_id': gr.getDisplayValue('sys_id'),
        'number':gr.getDisplayValue('number'),
        'company':gr.getDisplayValue('u_company'),
        'name':gr.getDisplayValue('journey_name'),
        'desc':gr.getDisplayValue('u_description'),
        'owner':gr.getDisplayValue('u_owner'),
        'asset_gen_status':gr.getDisplayValue('u_generation_status'),
        'timestamp_gen_status':gr.getDisplayValue('u_timestamp_status'),
        'status':gr.getDisplayValue('u_status'),
        'status_date':gr.getDisplayValue('u_status_date')
        });
    }
  objs;
 </g:evaluate>
}
0 REPLIES 0