Logging within Scoped UI Actopms

ian_mackey
Kilo Contributor

I am Trying to debug my UI action after trying to follow the template set out in this blog

Client & Server Code in One UI Action - ServiceNow Guru

Both styles of logging do not seem to work in my code.   I am not sure if doing this within a scoped application requires more permissions or something else.

Any Ideas ?   I do not see any messages at the top of my screen nor messages below the number field

Here is my code:

find_real_file.png

1 ACCEPTED SOLUTION

Hi Ian,



Thanks for the update. There was error on how you were displaying info message. Syntax is gs.info. I see you mentioned in your code as gs.Info(Error with Caps I)


Here is the final script :


runBusRuleCode();






//Server-side function


function runBusRuleCode(){


  gs.addInfoMessage('IAY Package is ' + current.location_package.getDisplayValue());




  try{



  // var collectionGr = new GlideRecord('x_enig_extreme_quo_product_collection_location');


  var collectionGr = new GlideRecord('incident');


  gs.addInfoMessage('INIT gr');




  collectionGr.addQuery('collection_id', current.location_package.getDisplayValue()); //if this is customf ield then it should be u_collection_id


  collectionGr.query();



  gs.addInfoMessage('preLoop');



  }


  catch(e)


  {gs.info("Error: " + e);


}




gs.addInfoMessage('IAY in UI Action');




action.setRedirectURL(current);


}




Also collection_id referenced in line 18 doesn't looks to be OOTB field on incident table. If this is custom field then it should be u_collection_id. Please make changes and let me know.


View solution in original post

10 REPLIES 10

Thank you Ian.



What is 'location_package'? It's not a standard task or incident field.


Hi Ian,



Thanks for the update. There was error on how you were displaying info message. Syntax is gs.info. I see you mentioned in your code as gs.Info(Error with Caps I)


Here is the final script :


runBusRuleCode();






//Server-side function


function runBusRuleCode(){


  gs.addInfoMessage('IAY Package is ' + current.location_package.getDisplayValue());




  try{



  // var collectionGr = new GlideRecord('x_enig_extreme_quo_product_collection_location');


  var collectionGr = new GlideRecord('incident');


  gs.addInfoMessage('INIT gr');




  collectionGr.addQuery('collection_id', current.location_package.getDisplayValue()); //if this is customf ield then it should be u_collection_id


  collectionGr.query();



  gs.addInfoMessage('preLoop');



  }


  catch(e)


  {gs.info("Error: " + e);


}




gs.addInfoMessage('IAY in UI Action');




action.setRedirectURL(current);


}




Also collection_id referenced in line 18 doesn't looks to be OOTB field on incident table. If this is custom field then it should be u_collection_id. Please make changes and let me know.


Nice catch on the gs.Info(). Very hard to see!


Hi Ian,



Can you uncomment 11th line in your script. Also please paste whole script here(copy and paste the script) so that we can take a look.


Hi Pradeep,



Line 11 was commented out because we turned off the client capability in the UI action. There's no client code to be found so it was just overhead. We decided to run it all server side and turn off that field and make it all server side for testing.