cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
How to write self-updating JMP add-ins
Jeff_Perkinson
Community Manager Community Manager

Setting up an ‘Add-in Depot’ makes it easy to administer a collection of self-updating JMP add-ins. In this example, the Depot is nothing more than a folder containing:

  • The JMP add-in file “com.jmp.brady.addin1.jmpaddin”.
  • A metadata file, “File Metadata.jmp”.

6695_AddinDepot1.pngIn a typical case, the add-in depot will reside on a server folder where add-in users have read access.The metadata file is a JMP table that stores information about each add-in in the depot. In this example, we will use it to check when the add-in was most recently published.6696_AddinDepot2.pngIf the add-in is current when the user runs it, the add-in will run without fanfare. However, if the user attempts to run an outdated version of the add-in, he or she will receive a prompt to install the new version:6697_AddinDepot3.pngIf the user clicks “Cancel”, the present addin will run. If he or she clicks “OK” the update will install automatically, overwriting the outdated version. In this example, the user is informed of the install and prompted to re-run the addin:

6698_AddinDepot4.png

Self-updating JMP add-ins: a step-by-step example.


  1. Open “Hello Script.jsl”.
    1. Ensure line that 10 has the date 08/01/2012 between the quotes.
    2. Ensure that line 22 has the string “Hello world” as the textbox argument.
    3. Note: Line 15 calls the check_for_updates function, which is not contained in our main script, but is contained in “update_functions.jsl”. This is the reason for the include statement on line 13. This is nice because it keeps our main script simpler, but we will need to make sure to include “update_functions.jsl” as an extra file whenever we build an add-in.
    4. Save and close the file.

6699_AddinDepot5.png

  1. Open “File Metadata.jmp”:
    1. Note that the filename in the “File” column must be the same as the string assigned to “Addin_Name” in line 11 of the script above.
    2. Ensure the publish date is 08/01/2012, Change it if needed, then save and close.

6700_AddinDepot6.png

  1. Open “update_functions.jsl”:
    1. On line 4, set the depot_path variable to the folder you will use for your depot.
    2. Note that the meta_file variable on line 5 must match the name of the metadata file.
    3. Save and close this file.

6701_AddinDepot7.png

  1. Build the add-in:
    1. From the JMP menu, select File >> New >> New Add-In
    2. On the ‘General Info’ tab:
      1. Enter the add-in name, in this example “Hello World”.
      2. Enter the add-in ID. Whatever you enter here must exactly match both the File column in the Metadata file, and the Addin_Name string in “Hello Script.jsl”.

6702_AddinDepot8.png

  1. On the ‘Menu Items’ tab:
    1. Click the “Add” button.
    2. In the ‘General’ panel’s ‘Menu item name” textbox, enter the name you would like to appear on the Add-in drop-down menu.
    3. In the ‘Action’ panel, select the ‘Run JSL in this file:’ radio button.
    4. Click ‘Browse’ and add the “Hello Script.jsl” file.

6703_AddinDepot9.png

  1. On the ‘Additional Files’ tab:
    1. Click ‘Add’.
    2. Browse to the “update_functions.jsl” file and add it.
    3. Click ‘Save’, and save the new .jmpaddin file to a convenient location.

6704_AddinDepot10.png

  1. Set up the depot:
    1. Place the .jmpaddin file you just created, along with the file “File Metadata.jmp”, in the folder you specified as your add-in depot folder (line 4 of the “update_functions.jsl” file.)
  1. Test the addin:
    1. From the JMP menu bar, select Add-Ins >> Hello World (or, whatever you entered as the menu item text), and the simple “Hello World” window will appear.
    2. Click ‘OK’ to close the window.

 

  1. Create an updated version of the add-in:
    1. Open “Hello Script.jsl”.
      1. Change line 10 to have the date 10/01/2012 between the quotes.
      2. Change line 22 to have string “Hellooooooooo world” as the textbox argument.
      3. Save and close the file.
      4. Perform steps 4a through 4d exactly as before, with the following important exception:
        1. When building the add-in, on the ‘General Info’ tab, make sure the “Install after save” box is NOT checked.
      5. Place the .jmpaddin file you just built in the depot, overwriting the older .jmpaddin file.

Note that we have not yet published the add-in, as we have yet to change the publish date in the metadata file. To see this, from the JMP menu select Add-Ins >> Hello World (or whatever you entered as the menu item text) and the “Hello World” window will appear as before.

  1. Publish the add-in:
    1. Open “File Metadata.jmp”. Change the publish date to 10/01/2012. Save and close the file.
  1. Test the automatic update:
    1. From the JMP menu, select Add-Ins >> Hello World. The add-in will determine that an update is available, and present you with the update window.
    2. Click ‘Cancel’ to refuse the update and see the “Hello World” window as before.
    3. Select Add-Ins >> Hello World to run the add-in again.
    4. This time, when the update window appears, click ‘OK’ to accept the update.
    5. Click ‘OK’ to close the confirmation window.
    6. Run the add-in again. The new add-in will run, showing “Hellooooooooo World” as the window text.
Comments
vkessler

Hi, this sounds very useful. Unfortunately it didn´t work for me (it was all fine until the last point f.).

Is it possible that something (Root? Folder?) in the "File Metadata.jmp" has to be changed?

Edit:

There was a naming issue in my case. I was able to fix the issue by setting the following names identical:

- Add-In Name

- Add-In ID

- File in "File Metadata.jmp"

- the filename of the jmpaddin

I named all these: "Foo.jmpaddin"

Now it works like a charme!

Hi Jeff,

 

This works really nice for controlling add-ins with a group or Team .

I have a small problem with it, when I do the update as from your instructions I always get this message. 

 

"Update Version is still available"

 

When I click OK the install happens, but the next time again the message appears.

I believe it has something to do with the different time Zones, I am in the UK.

I have updated the time Zone in the metafile "Publish Date" to d/m/y.

I have updated the start of the script line 10 "in format" to dd/mm/yyyy.

Does anything need updated in the "Update function" file ?

Any help appreciated.

 

@ivan_j_moore I had the same issue (international company) so I switched to using the add-in version number instead of the date. So basically:

// Get the installed JMP AddIn version
installedAddIn = Get Addin(  "com.jmp.brady.addin1.jmpaddin" );
installedAddInVer = installedAddIn << version;

addinLocation = "http://gitlab.contoso.com/addin/updateLocation/addin1.jmpaddin";

depot_path = "http://gitlab.contoso.com/addin/updateLocation/";
meta_file = "File Metadata.csv";

Try(
	dtm = Open( depot_path || meta_file, invisible );
	r = ((dtm << selectwhere( :File == "addin1.jmpaddin" )) << get selected rows)[1];
	mostrecent = Column( dtm, "Version" )[r];,
	print("Cannot access update site.");
	mostrecent = installedAddInVer;
	Throw("AddIn cannot check for updates.");
);


	If( mostrecent != installedAddInVer,
		requestUpdate( mostrecent, installedAddInVer, addinLocation);
	);
		
Close( dtm, nosave );

The tradeoff (I guess you could call it that?) is that the version number in the AddIn and the version column (in place of the date column) in File Metadata have to be the same for each new version, but that's not that big a deal (still have to update the date anyway). I also switched to .csv for File Metadata because I have a Python script that builds JMP add-ins and Python can't write .jmp files. I really ought to make a post about that script...

Recommended Articles