Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TIL Series based on #til stuff on slack and kalai #183

Open
jacebenson opened this issue May 20, 2020 · 1 comment
Open

Add TIL Series based on #til stuff on slack and kalai #183

jacebenson opened this issue May 20, 2020 · 1 comment

Comments

@jacebenson
Copy link
Owner

jacebenson commented May 20, 2020

#TIL

  • Today I learned that connection_test.do give you this handy measuring tool.
    LinkedIn: https://www.linkedin.com/posts/iamkalai_til-servicenow-activity-6668864912032460800-Biho

    • Source: Woz
  • Scheduling from a template. Would've always used a scheduled job/script.
    Link: https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/administer/form_administration/task/t_ScheduleATemplate.html

    • Source: Ashley
  • While JSUtil.notNil is awesome, do keep in mind that it does not work for empty object. Use JSUtil.isEmpty for checking objects.

    // Sample:
    gs.print("This does not work for object JSUtil.notNil({}):"+JSUtil.notNil({}));
    gs.print("This works for empty object JSUtil.isEmpty({}):"+JSUtil.isEmpty({}));
    
    var obj = {a:1};
    gs.print("Not a empty object JSUtil.isEmpty(obj):"+JSUtil.isEmpty(obj));
    • Source: Kalai
  • You may know that get() function can accept two arguments. When you pass two arguments, the first becomes the column for searching and the second is the value. But you should also know that get() can return multiple records based on the condition passed. So do not write your script under the assumption that get() will return only one record.

    var incident = new GlideRecord('incident');
    if (incident.get('caller_id', gs.getUserID())) { //This returns more than one record
      gs.print(incident.number);
      incident.next(); //You can iterate to next record like a normal gliderecord query
      gs.print(incident.number);
    }
    • Source: Kalai
  • report.view event gets triggered by the platform whenever you view a report in ServiceNow. The event is also generated when the report is run via scheduled report.

    • Source: Kalai
  • You can rollback fix scripts. Why this isn’t on the form by default and why it is set to do this is beyond me. /shrug.
    Link: https://jace.pro/post/2020-04-23-fix-scripts-can-rollback-now/

    • Source: Jace
  • What: GlideElement actually includes most of the String.prototype functions. Thus current.description.toUpperCase() for instance converts description to uppercase.

    • Source: János Szentpáli
  • sp_rel_widget_clone holds the relationship from which the widget was cloned.

  • If you want to relink your scoped app to a new repo, you have to delete the existing repo link for the app from sys_repo_config table. Deleting the existing link will allow you to use studio to add the new repo link.

  • What: #til : The evil of toString() - Regex strikes back
    Spent few hours tracking this down as Replace method won't support regex for objects. What a fun Friday this was.

    // Simplified code:
    
    var uri = gs.action.getGlideURI()
    var object = uri.toString();
    var string = uri+"";
    
    gs.print(uri);
    //gs.print(object.replace(/sys_scripts/,'')); //throws an error.
    gs.print(string.replace(/sys.scripts/,''));
    
    gs.print(typeof object);
    gs.print(typeof string);
  • g_user object is not available for client scripts on service portal widget. You can instead use glideUserSession object to retrieve the same info.

@jacebenson
Copy link
Owner Author

  • How to get a GlideRecord on the right table in one line;
    • GlideRecordUtil().getGR("<table_name>","<sys_id>")
    • Source: chait

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant