function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
grigri9grigri9 

any way to get package version number as a string?

I have a very simple visualforce page that I'd like to add to my managed package that prints out:

 

your installed package version is: 1.1

I realize an admin can just look this up or I can store this type of info in a custom setting but bear with me. 

 

So far I've found two possible ways to do this in code but both of them have drawbacks.

 

1) Have a function along the following lines:

 

if(Package.Version.Request == Package.Version.1.0))
  version = '1.0';
else if(Package.Version.Request == Package.Version.1.1))
  version = '1.1';
else if(Package.Version.Request == Package.Version.2.0))
  version = '2.0';		

This works but I would have to update this function every time I create a new package version.


2) output the package.version.request object directly onto a visualforce page. I can output the following: 

 

your installed package version is: Version[$namespace.1.1]

 

It's fairly straightforward to parse the numbers out of here but this will stop working if salesforce changes hows they output this object. 

 

It's ridiculous but there aren't any functions like Package.Version.GetMajorNumber or Package.Version.GetMinorNumber. Does anyone know of a better method of doing this?

admintrmpadmintrmp

A feature that would be a nice to have.

 

I've been hardcoding the version number each time I do an update.