Current Object not accessible in the UI Action

reginabautista
Kilo Sage

Hi guys,

I couldn't make the this code work. For some reason it's stopping at this line:     gr.addQuery('u_parent', current.sys_id);

When I debugged, current object is null. I'm having a scratching-my-head moment! Any help is greatly appreciated. Thanks

Note:

This is being called in UI Action

'Client' is checked

onClick = myFunction()

function myFunction(){

  var hasRecord = false;

  var gr = new GlideRecord('u_cost_model');

  gr.addQuery('u_parent', current.sys_id);

  gr.query();

  if(gr.hasNext()){

  hasRecord = true;

  }

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Regina,



You don't want this to be a client script... There is nothing client side about it.



Uncheck Client.


Remove the function call.



Script:


  var hasRecord = false;


  var gr = new GlideRecord('u_cost_model');


  gr.addQuery('u_parent', current.sys_id);


  gr.query();


  if(gr.hasNext()){


        hasRecord = true;


  }


View solution in original post

3 REPLIES 3

Chuck Tomasi
Tera Patron

Hi Regina,



You don't want this to be a client script... There is nothing client side about it.



Uncheck Client.


Remove the function call.



Script:


  var hasRecord = false;


  var gr = new GlideRecord('u_cost_model');


  gr.addQuery('u_parent', current.sys_id);


  gr.query();


  if(gr.hasNext()){


        hasRecord = true;


  }


Working now, thanks Chuck!


I'm glad you got your question answered. Thank you for participating in the community.