Showing results for 
Show  only  | Search instead for 
Did you mean: 

Practice JMP using these webinar videos and resources. We hold live Mastering JMP Zoom webinars with Q&A most Fridays at 2 pm US Eastern Time.See the list and register. Local-language live Zoom webinars occur in the UK, Western Europe and Asia. See your country site.

Choose Language Hide Translation Bar
Next-Level Automation Using JSL Scripting

Workflows are a no-code way to automate analyses and reports you use often or daily. In addition, you can convert the workflows to JSL scripts to offer a smooth user experience and more polished presentation.  This demo shows the basics of how to understand and modify workflow scripts and make them more flexible for new data and new users. It assumes you have some background in creating a JMP Workflow.


The case study uses three sources that we use to build the workflow using data from the years 2015-2017 and then make a script that can work with data from subsequent years.


The attached .zip file includes all the files you need to practice, including, two versions of the childcare Excel data and the Childcare Analysis JMP Add-In.



See how to:

  • Understand some of the JSL basic components
    • Comments
    • Referring to columns in data tables
    • Expressions and objects to which they refer
    • Path variables
  • Create Workflow
  • Save out the workflow script
  • Edit the script to generalize for new data and new users
    • Change table names and file paths
    • Create data table name variables
  • Add user input mechanisms as needed (Pick File, Column Dialog, etc.)
    • Choose a file
      • Create JSL to pick a file based on specific criteria
      • Default to current open data table
    • Choose a column and then unload the selected column from the dialog, to act on it later in the script.
    • Use embedded report Column Switcher rather than choose a column
  • Optionally save the script as a JMP add-in for distribution
  • Create the Add-in using File > New > Add-in
    • Create a menu item and/or a toolbar item to launch the script
    • Include data files, PDFs, etc.
    • Install the add-in and share with other users that can install by double-clicking on the *.jmpaddin file


Questions answered by Jordan Hiller @Jordan_Hiller  and Christian Bille @ChristianBille  at the live webinar:


Q: If my workflow generates a NEW table in the process, and that new table then gets called by successive steps, I encounter issues with this because the newly formed table will be given a hard-to-predict name, like “untitled 5.” Can this step be “generalized” in a similar way?

A: The place where you will run into it especially is when you are using things in the Tables menu like stack and split and transpose, and the things that you make with stack, split, transpose. Unless you give them an explicit name, they will be called u=Untitled 17 or Untitled 32. So, name the new Output Table during the Tables menu operations.





Renamed split tableRenamed split table









Q: If a JSL script was run without Workflow Builder, how can it be turned into a Workflow?

A: Yes, you can create a new Workflow Custom Action, then copy and paste the script into a window, or break the script up into separate Custom Actions.  See below.




Q: Could you hit Record in Workflow Builder, then run you script? Would WFB capture the steps of the script?

A: No, it will not capture the steps.


Q: Do you have any suggestion when running Fit Model with "by" variable? Workflow save out an instance, which has breakdown of each category? But how to make it more general when the column has new category?

A: By group scripting by groups in JSL is a bit tricky.  You have to know how to handle JSL lists.  I suggest you consult the JMP User community or submit a question to the User Community, and you'll get some good advice there.


Q: Is there a path variable that refers to the directory where the current running script is located?

A: No, there is not a path variable for the script. You can get around that. a lot of times when you specify a file in a JMP script, if the file lives in the same path/directory/folder in the same script you are running, you can remove the path/directory from the filename and use a relative path.  See below.







Adding @Jordan_Hiller  and @ChristianBille to this comment.

Thank you all for putting this together. I have a follow-up question on "generalizing," and it has more to do with my lack of scripting ability. Normally in my workflow, I need to "select all columns" and then do something, whether it be summarize, group, explore missing values, etc. However, I have thousands of columns, and they will have different names in each new data table, so I can't just replace 5,000 columns when it prompts me that it can't find one particular column (would take hours). I am wondering if I can group the columns FIRST and then carry out the remaining workflow steps on the group. I could give the group a generic name.


The alternative would be to try to select columns by a property in their name, as in the script below. If there way to script it to where the next step in the workflow features the SELECTED columns generated by this script? For instance, if I wanted to transpose all columns with "the" in the name, could this script be embedded in a workflow? I'm trying to think of how to circumvent having to recode column names in each file, though that is yet another option!


I realize Workflow Builder likely works best when you've got dozens of identically formatted tables to crunch, but I am trying to figure out if I could get it to cooperate when each table differs slightly.

names default to here(1);
dt=current data table();
colNames = dt << get column names(string);

for each({Name}, colNames,
		for each row(
			column(name)[row()] = ???????????;  // your formula here


If I understand your question, @abmayfield, you're asking if a JMP17 workflow can accommodate a large number of changing column names. I'll say yes it's possible, but not without inserting some custom JSL into the workflow.

One good approach is to have your workflow/script act on the columns that the user selected before running the workflow. 

Here's an example using the Blood Pressure sample data set.

Names Default To Here( 1 );

//Custom JSL: Get the user-selected columns, save them into list CNames
CNames = Current Data Table() << Get Selected Columns;

//Slightly modified workflow step: replace hard-coded columns with list CNames
Data Table( "Blood Pressure" ) << Transpose(
	columns( CNames ),
	By( :Dose ),
	Label( :Subject ),
	Output Table( "tdata" )

However you attack this, the solution will probably involve JSL lists. Learning a little bit about lists can give you new coding superpowers! 


Recommended Articles