<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to prompt user to name SQL query output data table and add date and time to filename? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-prompt-user-to-name-SQL-query-output-data-table-and-add/m-p/392578#M64280</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;I am asking for your expert advice on the following topic, since I am really new to JMP scripting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made a SQL query (invisible) through the Query builder but I need help to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- prompt the user to insert data table file&lt;SPAN style="font-family: inherit;"&gt;&amp;nbsp;name (pop-up window);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;- add date and time (&lt;CODE class=" language-jsl"&gt;ddmonyyyy:h:m:s&lt;/CODE&gt;) to the output data table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I managed to script is here below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt=New SQL Query(
	Version( 130 ),
	Connection(
		"ODBC:DSN=DB001.00.G_FE_JMP15;DBQ=Y:\OFFICIAL_DATABASES\QA_Admin\Stability\DB001.00.G.StabilityStudies_FE_StudiesCompiler_JMP15.accdb;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;UID=admin;"
	),
	QueryName( "Query_DB001.00.G.StabilityStudies_FE_StudiesCompiler_10Jun2021" ),
	Select(
Column( "StudyID", "t1" ),
		Column( "TimePointID", "t1" ),
		Column( "StabilityClimaticConditions", "t1" ),
		Column( "TestMonth", "t1" ),
		Column( "ProgramComments", "t1" ),
		Column( "Test1", "t1" ),
		Column( "Test1Specification", "t1" ),
		Column( "Test1Units", "t1" ),
		Column( "Test 01", "t1" ),
		Column( "intTest1", "t1" ),
		Column( "Test2", "t1" ),
		Column( "Test2Specification", "t1" ),
		Column( "Test2Units", "t1" ),
		Column( "Test 02", "t1" ),
		Column( "intTest2", "t1" ),
		Column( "Test3", "t1" ),
		Column( "Test3Specification", "t1" ),
		Column( "Test3Units", "t1" ),
		Column( "Test 03", "t1" ),
		Column( "intTest3", "t1" ),
		Column( "Test4", "t1" ),
		Column( "Test4Specification", "t1" ),
		Column( "Test4Units", "t1" ),
		Column( "Test 04", "t1" ),
		Column( "intTest4", "t1" ),
		Column( "Test5", "t1" ),
		Column( "Test5Specification", "t1" ),
		Column( "Test5Units", "t1" ),
		Column( "Test 05", "t1" ),
		Column( "intTest5", "t1" ),
From( Table( "qry_ResultsUnion01_35", Alias( "t1" ) ) ),
	Where(
		EQ(
			Column( "StudyID", "t1" ),
			_AllRows_,
			UI(
				Comparison(
					Base(
						"Continuous",
						Prompt(
							"StudyID:",
							Character,
							PromptName( "t1.StudyID_1" )
						)
					)
				)
			)
		) &amp;amp; In List(
			Column( "StabilityClimaticConditions", "t1" ),
			_AllRows_,
			UI(
				SelectListFilter(
					ListBox,
					Base(
						"Categorical",
						Prompt(
							"StabilityClimaticConditions:",
							Character,
							PromptName( "t1.StabilityClimaticConditions_1" )
						)
					)
				)
			)
		)
	)
	) &amp;lt;&amp;lt; Run Background(invisible);


nw = New Window( "Name data table",
	&amp;lt;&amp;lt;Modal,
	&amp;lt;&amp;lt;Return Result,
	Text Box( "Insert data table file name" ),
	tableName = Text Edit Box( " ", &amp;lt;&amp;lt;set width( 400 ) )
);
If( nw["button"] == 1 &amp;amp; nw["tableName"] != "",
	dt &amp;lt;&amp;lt; set name( nw["tableName"] ),
	dt &amp;lt;&amp;lt; save as("tableName"||Format Date( Today(), "ddmonyyyy:h:m:s" )||".jmp");
	);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;F&lt;/P&gt;</description>
    <pubDate>Sat, 10 Jun 2023 23:31:39 GMT</pubDate>
    <dc:creator>FabioSaragoni</dc:creator>
    <dc:date>2023-06-10T23:31:39Z</dc:date>
    <item>
      <title>How to prompt user to name SQL query output data table and add date and time to filename?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-prompt-user-to-name-SQL-query-output-data-table-and-add/m-p/392578#M64280</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;I am asking for your expert advice on the following topic, since I am really new to JMP scripting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made a SQL query (invisible) through the Query builder but I need help to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- prompt the user to insert data table file&lt;SPAN style="font-family: inherit;"&gt;&amp;nbsp;name (pop-up window);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;- add date and time (&lt;CODE class=" language-jsl"&gt;ddmonyyyy:h:m:s&lt;/CODE&gt;) to the output data table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I managed to script is here below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt=New SQL Query(
	Version( 130 ),
	Connection(
		"ODBC:DSN=DB001.00.G_FE_JMP15;DBQ=Y:\OFFICIAL_DATABASES\QA_Admin\Stability\DB001.00.G.StabilityStudies_FE_StudiesCompiler_JMP15.accdb;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;UID=admin;"
	),
	QueryName( "Query_DB001.00.G.StabilityStudies_FE_StudiesCompiler_10Jun2021" ),
	Select(
Column( "StudyID", "t1" ),
		Column( "TimePointID", "t1" ),
		Column( "StabilityClimaticConditions", "t1" ),
		Column( "TestMonth", "t1" ),
		Column( "ProgramComments", "t1" ),
		Column( "Test1", "t1" ),
		Column( "Test1Specification", "t1" ),
		Column( "Test1Units", "t1" ),
		Column( "Test 01", "t1" ),
		Column( "intTest1", "t1" ),
		Column( "Test2", "t1" ),
		Column( "Test2Specification", "t1" ),
		Column( "Test2Units", "t1" ),
		Column( "Test 02", "t1" ),
		Column( "intTest2", "t1" ),
		Column( "Test3", "t1" ),
		Column( "Test3Specification", "t1" ),
		Column( "Test3Units", "t1" ),
		Column( "Test 03", "t1" ),
		Column( "intTest3", "t1" ),
		Column( "Test4", "t1" ),
		Column( "Test4Specification", "t1" ),
		Column( "Test4Units", "t1" ),
		Column( "Test 04", "t1" ),
		Column( "intTest4", "t1" ),
		Column( "Test5", "t1" ),
		Column( "Test5Specification", "t1" ),
		Column( "Test5Units", "t1" ),
		Column( "Test 05", "t1" ),
		Column( "intTest5", "t1" ),
From( Table( "qry_ResultsUnion01_35", Alias( "t1" ) ) ),
	Where(
		EQ(
			Column( "StudyID", "t1" ),
			_AllRows_,
			UI(
				Comparison(
					Base(
						"Continuous",
						Prompt(
							"StudyID:",
							Character,
							PromptName( "t1.StudyID_1" )
						)
					)
				)
			)
		) &amp;amp; In List(
			Column( "StabilityClimaticConditions", "t1" ),
			_AllRows_,
			UI(
				SelectListFilter(
					ListBox,
					Base(
						"Categorical",
						Prompt(
							"StabilityClimaticConditions:",
							Character,
							PromptName( "t1.StabilityClimaticConditions_1" )
						)
					)
				)
			)
		)
	)
	) &amp;lt;&amp;lt; Run Background(invisible);


nw = New Window( "Name data table",
	&amp;lt;&amp;lt;Modal,
	&amp;lt;&amp;lt;Return Result,
	Text Box( "Insert data table file name" ),
	tableName = Text Edit Box( " ", &amp;lt;&amp;lt;set width( 400 ) )
);
If( nw["button"] == 1 &amp;amp; nw["tableName"] != "",
	dt &amp;lt;&amp;lt; set name( nw["tableName"] ),
	dt &amp;lt;&amp;lt; save as("tableName"||Format Date( Today(), "ddmonyyyy:h:m:s" )||".jmp");
	);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;F&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:31:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-prompt-user-to-name-SQL-query-output-data-table-and-add/m-p/392578#M64280</guid>
      <dc:creator>FabioSaragoni</dc:creator>
      <dc:date>2023-06-10T23:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to prompt user to name SQL query output data table and add date and time to filename?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-prompt-user-to-name-SQL-query-output-data-table-and-add/m-p/392824#M64307</link>
      <description>&lt;P&gt;Try changing your last if statement to this, it both fixes your tableName reference and removes the slashes and colons that were probably causing your issue:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//ask where to save the file (could skip this or define it in code)
fldr = pick directory( "Select where to save the file", "$Temp" );

//Save the file
If( nw["button"] == 1 &amp;amp; nw["tableName"] != "",
	dt &amp;lt;&amp;lt; set name( nw["tableName"] );
	dt &amp;lt;&amp;lt; save as( fldr || nw["tableName"] || Format Date( Today(), "yyyymmdd" ) || "-" || Char( Hour( Today() ) ) || Char( Minute( Today() ) ) || Char( Second( Today() ) ) || ".jmp");
);

//Open directory where file was saved (not needed)
Open(fldr);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Jun 2021 21:32:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-prompt-user-to-name-SQL-query-output-data-table-and-add/m-p/392824#M64307</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2021-06-11T21:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to prompt user to name SQL query output data table and add date and time to filename?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-prompt-user-to-name-SQL-query-output-data-table-and-add/m-p/393046#M64337</link>
      <description>&lt;P&gt;Thanks for your reply!&lt;/P&gt;&lt;P&gt;I still have an issue at this level:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; set name( nw["tableName"] );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The error message I get is here below&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FabioSaragoni_1-1623657138473.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/33509i477B9BCEA5998D08/image-size/medium?v=v2&amp;amp;px=400" role="button" title="FabioSaragoni_1-1623657138473.png" alt="FabioSaragoni_1-1623657138473.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please help me solve it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;F&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 08:31:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-prompt-user-to-name-SQL-query-output-data-table-and-add/m-p/393046#M64337</guid>
      <dc:creator>FabioSaragoni</dc:creator>
      <dc:date>2021-06-14T08:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to prompt user to name SQL query output data table and add date and time to filename?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-prompt-user-to-name-SQL-query-output-data-table-and-add/m-p/393063#M64340</link>
      <description>&lt;P&gt;Most likely execution of your script finishes before the New Query(.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try running the query in foreground instead of background OR use modal before query to get values from user and use postquery script to change the name after query finishes.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 08:56:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-prompt-user-to-name-SQL-query-output-data-table-and-add/m-p/393063#M64340</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2021-06-14T08:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to prompt user to name SQL query output data table and add date and time to filename?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-prompt-user-to-name-SQL-query-output-data-table-and-add/m-p/393075#M64342</link>
      <description>Executing the query in foreground solved the issue!&lt;BR /&gt;&lt;BR /&gt;Thank you so much,&lt;BR /&gt;Fabio&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Jun 2021 11:59:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-prompt-user-to-name-SQL-query-output-data-table-and-add/m-p/393075#M64342</guid>
      <dc:creator>FabioSaragoni</dc:creator>
      <dc:date>2021-06-14T11:59:12Z</dc:date>
    </item>
  </channel>
</rss>

