How do I get the application version number?

peterburkitt
Kilo Contributor

I want to display the scoped application version number on a Programmatic Content Block so I need a way to get it using jelly scripting (if possible).

To be clear I mean the version of our scoped application which is installed on their SN instance, not the version of ServiceNow or anything like that.

Chuck Tomasi
Tera Patron

Hi Peter,



The application version number is store in the sys_app table in the version field.



find_real_file.png


Great, that works, but it would be nice not to have to find the record that refers to the current app. Is there a scoped sys property for the current app's sys id or something?


Here's what I have now:



<g2:evaluate var="jvar_version">
        var grSysApp = new GlideRecord('sys_app');
        grSysApp.addQuery('name', 'STARTSWITH', 'Sync Services');
        grSysApp.addQuery('scope', 'x_suel_asset_meta');
        grSysApp.query();
             
              var version = '';
             
              if (grSysApp.next()) {
                  version = 'Version ' + grSysApp.version;
        }
         
              version;
</g2:evaluate>
<p class="version">$[jvar_version]</p>


If you wanted to use a property for your custom app, you would need to make it a standard part of your app and manage it separately from the Version field. Sounds a bit like a duplicate effort. Adding your code to a script include and just calling a method like "getVersion()" might make it easier to manage in your Jelly code (as well as other places.) Just a thought.


Sadly that solution fails once the app is installed somewhere as sys_app is empty on the target instance