Gel is not working in portal

piyush-kalra
Tera Contributor

Reset List collector and set according to location data in list collector working in ITIL view but not working in portal

Check below code:

var collectorName = '';

  var filterString = '';

  if (newValue != '') {

  //Apply a filter to the list collector variable

  collectorName = 'prod_access_to_approver_po_enabler_role';

  filterString = 'u_region=' + newValue;

  //alert("in onchange" +filterString );

  // Gets the right column of the List Collector

  var rightBucket2 = gel(collectorName + '_select_1');

  // Loops through all the selected entries and remove them

  while (rightBucket2.firstChild) {

  if (rightBucket2.firstChild != null && rightBucket2.firstChild != '') {

  rightBucket2.removeChild(rightBucket2.firstChild);

  }

  }

  //Find the filter elements

  var fil = gel('ep');

  //Hide the filter elements

  // fil.rows[0].style.display = 'none';

  // fil.rows[1].style.display = 'none';

  // fil.nextSibling.rows[0].style.display = 'none'; //Filter description text

  //Reset the filter query

  eval(collectorName + 'g_filter.reset()');

  eval(collectorName + 'g_filter.setQuery("' + filterString + '")');

  eval(collectorName + 'acRequest(null)');

  setTimeout(setCollectorFilter, 1000);

  }

var collectorName1 = '';

  var filterString1 = '';

  if (newValue != '') {

  if (newValue == 'Africa')

  {

newValue="Africa";  

  }

else if (newValue == 'America')

{

newValue="America";

}

else if (newValue == 'Jakrata')

{

newValue="Jakrata";

}

  //Apply a filter to the list collector variable

  collectorName1 = 'prod_access_to_approver_po_derived_role';

  filterString1 = 'u_region=' + newValue;

  //alert("in onchange" +filterString );

  // Gets the right column of the List Collector

  var rightBucket21 = gel(collectorName1 + '_select_1');

  // Loops through all the selected entries and remove them

  while (rightBucket21.firstChild) {

  if (rightBucket21.firstChild != null && rightBucket21.firstChild != '') {

  rightBucket21.removeChild(rightBucket21.firstChild);

  }

  }

Below error is coming in Service Portal:

js_includes_sp.jsx:63718 (g_env) [SCRIPT:EXEC] Error while running Client Script "Set role according to Region": ReferenceError: gel is not defined

9 REPLIES 9

hi,


gel is a jelly function . In service portal , you have to move all your code to UI Script and add the dependency to the your page ( See the Dependency menu in service portal ). So that you can access jQuery . After that, it is normal DOM manipulation using jQuery or vanilla javascript.




Thanks


- YLN


How i call in onchange client script??


jQuery wont be available in the client script runtime. It is only available in a widget's client controller and link function.


gel, as Dan said is a jelly function so it will also not be available in the portal.



Also, I believe that since the runtime for client scripts in the form or catalog form are isolated, even if you load it in as a UI script/ dependency those dependencies will not be available to use in a client script.




Vanilla JS is going to be your best option here.


I didn't realize that.   Thanks for the info Jesse and YLN.


Swathi12
Tera Expert

Hi Piyush,

 

Instead of the above code , for setting the list collector use : 

//arr[1] has the sys_id of the users
//arr[0] has the display name of the users
g_form.setValue('members', arr[1], arr[0]);

 

Please mark my answer helpful/correct if it answered your question.

 

Regards,

Swathi