Scripting Guide > Extending JMP > Share Reports on JMP Live > Publish Reports or Data to JMP Live
发布日期: 09/18/2023

Publish Reports or Data to JMP Live

New for 17: In the Publish command, you must specify either the space or the folder that you want to publish to.

Using JSL, you can publish JMP reports or data tables to JMP Live as posts. Posts are published to a space or to a folder in a space. Space access determines who can see your posts, so individuals or groups who have access to the space see your posts.

Publish to a Space

Depending on how you want to share your post, you can publish to a personal space or any other space using a space key. You can find a space’s key in JMP Live by going to a space and clicking the Details icon.

To publish a post to your personal space, enter a tilde (~) as a shortcut. Personal spaces always start with a tilde.

To publish a post to another space, specify the space key.

Tip: To share a post with all JMP Live users, specify the ALLUSERS space key. The post appears in the All Users space.

Example of Publishing to a Space

This example publishes a Graph Builder report to your personal space.

Names Default To Here( 1 );
// Open the Big Class data table.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Run the Graph Builder table script and call the report gbsmoother.
gbsmoother = dt << Run Script( "Graph Builder Smoother Line" );
// Set up the connection to the JMP Live server.
liveconnection = New JMP Live();
// Add the gbsmoother report to content.
content = New JMP Live Content( gbsmoother );

/* Publish the content to your personal space. Use the JMP Live Connection that you established and return a JMP Live object called jmpliveresult. */

jmpliveresult = liveconnection << Publish( content, Space( "~" ) );
// Close all data tables without saving.
Close All( Data Tables, NoSave );

Create a Folder in a Space

New for 17: Previously, you specified a title and a description for the Create Folder command. Now you must also specify the space to publish to. You can also publish a folder under an existing folder.

When you create a folder, who can see it depends on which space you create the folder in.

Example of Creating a Folder in a Space

This example creates a folder in your personal space.

Names Default To Here( 1 );
// Set up the connection to the JMP Live server.
liveconnection = New JMP Live();

/* Create a folder in your personal space with a title and a description. Use the JMP Live Connection that you established and return a JMP Live object called jmpliveresult. */

jmpliveresult = liveconnection << Create Folder( Space( "~" ), Title( "Create Folder Example" ), Description( "Folder created in the scripting index example script.") );
// Make the result scriptable.
folder = jmpliveresult << As Scriptable;
// Get the folder ID.
id = folder << Get ID();
// Output the folder ID to the JMP log.
Write( "ID: ", id );

Publish to a Folder in a Space

To publish to an existing folder in a space, you need the folder ID. You can find the folder ID in JMP Live by clicking on a folder. The ID appears in the URL, or you can click the Details icon and copy the Post ID.

Example of Publishing to a Folder in a Space

This example publishes a Graph Builder report to a folder in your personal space.

Names Default To Here( 1 );
// Open the Big Class data table.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Run the Graph Builder table script and call the report gbsmoother.
gbsmoother = dt << Run Script( "Graph Builder Smoother Line" );
// Set up the connection to the JMP Live server.
liveconnection = New JMP Live();

/* Create a folder in your personal space and give it a title. Use the JMP Live Connection that you established and return a JMP Live object called jmpliveresult. */

jmpliveresult = liveconnection << Create Folder( Space( "~" ), Title( "Publish to Folder Example" ) );
// Make the result scriptable.
folder = jmpliveresult << As Scriptable;
// Add the gbsmoother report to content.
content = New JMP Live Content( gbsmoother );

/* Publish the content to your personal space. Use the JMP Live Connection that you established and return a JMP Live object called jmpliveresult. */

jmpliveresult = liveconnection << Publish( content, Folder( ID( folder << Get ID ) ) );
// Close all data tables without saving.
Close All( Data Tables, NoSave );

Publish Multiple Reports to a Folder

New for 17: Previously, a new folder was automatically created when you published multiple reports. In 17, add the Create Folder command. Move the Title and Description from the Publish command into the Create Folder command. Then, modify the Publish command to remove the Title and Description, and publish to the folder that you just created.

Using JSL, you can publish multiple reports to an existing folder or you can create a folder during the publishing process.

Example of Publishing Multiple Reports to a Folder

This example publishes two Graph Builder reports to a folder in your personal space.

Names Default To Here( 1 );
// Open the Big Class data table.
bc = Open( "$SAMPLE_DATA/Big Class.jmp" );
/* Run two Graph Builder table scripts and call the reports gbsmoother and gbline. */
gbsmoother = bc << Run Script( "Graph Builder Smoother Line" );
gbline = bc << Run Script( "Graph Builder Line and Bar Charts" );
// Set up the connection to the JMP Live server.
liveconnection = New JMP Live();

/* Create a folder in your personal space with a title. Use the JMP Live Connection that you established and return a JMP Live object called jmpliveresult. */

jmpliveresult = liveconnection << Create Folder( Space( "~" ), Title( "Multiple Reports Example" ) );
// Make the result scriptable.
folder = jmpliveresult << As Scriptable;
// Add the gbsmoother report to content1.
content1 = New JMP Live Content( gbsmoother );
// Add the gbline report to content2.
content2 = New JMP Live Content( gbline );
// Publish content1 and content2 (in a list) to the newly created folder.
jmpliveresult = liveconnection << Publish( {content1, content2}, Folder( ID( folder << Get ID ) ) );
// Close all data tables in JMP without saving.
Close All( Data Tables, NoSave );
需要更多信息?有问题?从 JMP 用户社区得到解答 (community.jmp.com).