gel('sysparm_item_guid').value is not working with Istanbul version

vai
Kilo Contributor

Hi All,

I am trying to validate the attachment type on submit of request, noticed that   gel function is not supported with Istanbul version.

  var cat_id = gel('sysparm_item_guid').value;

   

    var gr = new GlideRecord("sys_attachment");

    gr.addQuery("table_name", "sc_cart_item");

    gr.addQuery("table_sys_id", cat_id);

    gr.query();

    while (gr.next()) {

      if(gr.getValue("content_type") != 'application/text'){//meaning if you find a file with xls extension

              //do something

       

              return false;

      }

what is the alternative for gel('sysparm_item_guid').value ?

1 ACCEPTED SOLUTION

Hi Vineeth,



g_form.getValue('sysparm_item_guid') should work correctly in scoped app. But the problem is you cannot use GlideRecord   in client side in scoped app which leads to using GlideAjax in onSubmit client script. It also has one issue that is getXMLWait() doesn't work in scoped app.


So this post gives you workaround on the same.


But you can try one more option



Create Catalog client script in global scope for that catalog item and use following script then it will stop form submission. I have tried the same way and it worked for me for catalog item present in scoped app



Script:


var cat_id = gel('sysparm_item_guid').value;


var gr = new GlideRecord("sys_attachment");


gr.addQuery("table_name", "sc_cart_item");


gr.addQuery("table_sys_id", cat_id);


gr.query();


if (!gr.next()) {


alert("Please add attachment");


return false;


}



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

9 REPLIES 9

bernyalvarado
Mega Sage

Hi Vineeth,



Are you referring on how to get a parameter that is incoming to something like a script include?



Please try something like:



var cat_id = this.getParameter('sysparm_item_guid');



Thanks,


Berny


Hi Berny,



All the options you have posted are working fine in global application scope, but mine is a scoped application and they are not working in the scoped application..



I see that even gel('sysparm_item_guid').value is working in global application scope not in my application scope.



any help on this why they are not working in my application scope ?


bernyalvarado
Mega Sage

In case you were referring to the client code and the function of get element, try using g_form.getValue(variableName); instead



Thanks,


Berny


bernyalvarado
Mega Sage

Within a client script you can also try:



g_form.getControl('variableName').value;



Thanks,


Berny