Publication date: 07/08/2024

Replace a JMP Live Report

To replace the contents of an existing report in JMP Live, you need the ID of the report that you want to replace. To find the report ID in JMP Live, click on a report post. The post ID appears in the URL, or you can copy the ID under Details.

When you replace an existing report, you choose how to update the data. You can use existing data on JMP Live, update the existing data on JMP Live, or publish a new data table.

Example of Replacing a Report Using Existing Data

This example publishes a Graph Builder report and its associated data to a folder in your personal space in JMP Live. Then, the report is replaced with a new Graph Builder report that uses the existing data.

Names Default to Here(1);

// Open the Big Class sample data table.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
/* Run two Graph Builder table scripts and call the reports gbsmoother and gbline. */
gbsmoother = dt << Run Script( "Graph Builder Smoother Line" );
gbline = dt << Run Script( "Graph Builder Line Chart" );
// 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( "Replace Example - Use Existing" ) );
// Make the result scriptable.
folder = jmpliveresult << As Scriptable;
// Add the gbsmoother report to content.
content = New JMP Live Content( gbsmoother );
// Publish the content to the newly created folder and get the folder ID.
jmpliveresult = liveconnection << Publish( content, Folder( ID(folder << Get ID) ) );
// Make the list of created posts scriptable.
postlist = jmpliveresult << As Scriptable;
// Get the details for the posts.
bcPostId = "";
reportId = "";
For( i = 1, i <= postlist << Get Number Of Items, i += 1,
	title = postlist[i] << Get Title();
	type = postlist[i] << Get Type();
	If( type == "Data",
		bcPostId = postlist[i] << Get ID
	);
	If( type == "Report",
		reportId = postlist[i] << Get ID
	);
);
// Add the gbline report to content.
content = New JMP Live Content( gbline );
// Specify in the Replace command to use the existing data.
jmpliveresult = liveconnection << Replace(
	content,
	ID( reportId ),
	Use Existing Data( {{"Big Class", bcPostId}} )
);
// Close all data tables in JMP without saving.
Close All( Data Tables, NoSave );

Example of Replacing a Report and Updating Existing Data

This example publishes a Graph Builder report and its associated data to a folder in your personal space in JMP Live. Then, the report is replaced with a new Graph Builder report that updates the existing data.

Note: All posts in JMP Live that use this data are updated.

Names Default to Here(1);

// Open the Big Class sample data table.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
/* Run two Graph Builder table scripts and call the reports gbsmoother and gbline. */
gbsmoother = dt << Run Script( "Graph Builder Smoother Line" );
gbline = dt << Run Script( "Graph Builder Line Chart" );
// 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( "Replace Example - Update Existing" ) );
// Make the result scriptable.
folder = jmpliveresult << As Scriptable;
// Add the gbsmoother report to content.
content = New JMP Live Content( gbsmoother );
// Publish the content to the newly created folder and get the folder ID.
jmpliveresult = liveconnection << Publish( content, Folder( ID(folder << Get ID) ) );
// Make the list of created posts scriptable.
postlist = jmpliveresult << As Scriptable;
// Get the details for the posts.
bcPostId = "";
reportId = "";
For( i = 1, i <= postlist << Get Number Of Items, i += 1,
	title = postlist[i] << Get Title();
	type = postlist[i] << Get Type();
	If( type == "Data",
		bcPostId = postlist[i] << Get ID
	);
	If( type == "Report",
		reportId = postlist[i] << Get ID
	);
);
// Add the gbline report to content.
content = New JMP Live Content( gbline );
// Specify in the Replace command to update the existing data.
jmpliveresult = liveconnection << Replace(
	content,
	ID( reportId ),
	Update Existing Data( {{"Big Class", bcPostId}} )
);
// Close all data tables in JMP without saving.
Close All( Data Tables, NoSave );

Example of Replacing a Report and Publishing New Data

This example publishes a Graph Builder report and its associated data to a folder in your personal space in JMP Live. Then, the report is replaced with a new Graph Builder report that replaces the existing report data with a new data table.

Names Default to Here(1);

// Open the Big Class sample data table.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
/* Run two Graph Builder table scripts and call the reports gbsmoother and gbline. */
gbsmoother = dt << Run Script( "Graph Builder Smoother Line" );
gbline = dt << Run Script( "Graph Builder Line Chart" );
// 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( "Replace Example - Publish New" ) );
// Make the result scriptable.
folder = jmpliveresult << As Scriptable;
// Add the gbsmoother report to content.
content = New JMP Live Content( gbsmoother );
// Publish the content to the newly created folder and get the folder ID.
jmpliveresult = liveconnection << Publish( content, Folder( ID(folder << Get ID) ) );
// Make the list of created posts scriptable.
postlist = jmpliveresult << As Scriptable;
// Get the details for the posts.
bcPostId = "";
reportId = "";
For( i = 1, i <= postlist << Get Number Of Items, i += 1,
	title = postlist[i] << Get Title();
	type = postlist[i] << Get Type();
	If( type == "Data",
		bcPostId = postlist[i] << Get ID
	);
	If( type == "Report",
		reportId = postlist[i] << Get ID
	);
);
// Add the gbline report to content.
content = New JMP Live Content( gbline );
// Specify in the Replace command to publish new data.
jmpliveresult = liveconnection << Replace(
	content,
	ID( reportId ),
	Publish New Data( {"Big Class"} )
);
// Close all data tables in JMP without saving.
Close All( Data Tables, NoSave );
Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).