发布日期: 09/18/2023

Replace a JMP Live Report

New for 17: Previously, replacing a report automatically used the existing data. Now you must specify what to do with the data. To mirror the previous behavior, use the Use Existing Data option.

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 click the Details icon and copy the post ID.

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" );
// Specify the space to use as your personal space.
spaceToUse = "~";
// 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;
// Get the folder URL.
folderURL = folder << Get URL;
// 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" );
// Specify the space to use as your personal space.
spaceToUse = "~";
// 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;
// Get the folder URL.
folderURL = folder << Get URL;
// 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 data with a new data table.

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" );
// Specify the space to use as your personal space.
spaceToUse = "~";
// 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;
// Get the folder URL.
folderURL = folder << Get URL;
// 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 );
需要更多信息?有问题?从 JMP 用户社区得到解答 (community.jmp.com).