Very Hot Topic (More than 25 Replies) [Solved] UserID attached to report filenames? (Read 3110 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
[Solved] UserID attached to report filenames?
Jan 30th, 2008 at 6:54pm
Print Post Print Post  
Is there a way to have a UserID added to the report filename (the html file) that is generated when a report is run?
« Last Edit: Feb 2nd, 2008 at 12:48am by Hammer »  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: UserID attached to report filenames?
Reply #1 - Jan 30th, 2008 at 6:55pm
Print Post Print Post  
Infinity wrote on Jan 30th, 2008 at 6:54pm:
Is there a way to have a UserID added to the report filename (the html file) that is generated when a report is run?

Not if you're running it manually. If you are running it in code using@PrintAReport, you can.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: UserID attached to report filenames?
Reply #2 - Jan 30th, 2008 at 7:05pm
Print Post Print Post  
Most of my reports are run via command buttons, and all the reports that I would need this for are done this way.

Here is the code I am using for my "Monthly Billed" button:
Code
Select All
// Prints the expanded Monthly Billing report for this month

Var vPrintTheReport as string

IF NOT @Mode() = 0
THEN
	{
	vPrintTheReport = @PrintAReport(".     Monthly Billed, this month", REPORT_MODE_HTML_PREVIEW, PRINT_ORIENTATION_PORTRAIT, 0, -1, -1, -1, -1, -1, -1)
	}
ELSE @MSGBOX("Reports can only be run in Update mode", "Please switch to Update and", "select the records you wish to run the report on.") 



Looking at the book, page 330, it seems like I would have to do something with vFilename, but I'm not sure what.  Thanks for your help Erika.
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: UserID attached to report filenames?
Reply #3 - Jan 30th, 2008 at 7:48pm
Print Post Print Post  
Infinity wrote on Jan 30th, 2008 at 7:05pm:
Looking at the book, page 330, it seems like I would have to do something with vFilename, but I'm not sure what.  Thanks for your help Erika.

You probably want to use @Shell or CreateAProcess to issue a command to your system to rename the file from vFilename to @UserID + "_" + vFilename. Or something like that, depending on what you are trying to do.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: UserID attached to report filenames?
Reply #4 - Jan 30th, 2008 at 8:07pm
Print Post Print Post  
Hmmm.  OK.  All I need is a simple Rename command.  My @PrintAReport code creates the filename as vPrintTheReport, and in Global code I've set a static variable sUserID = @UserID.  So the command would be something like

Code
Select All
REN F:\Sesame\Reports\vPrintTheReport vPrintTheReport+"_"+sUserID 



I don't think CreateAProcess is the way to go, probably @Shell.  I'm not sure how I can wrap the quotes into it, though.  OK, so maybe use another variable that adds them.  So I've got:
Code
Select All
var vUnderline as string
vUnderline = "_" 



So then it becomes

Code
Select All
REN F:\Sesame\Reports\vPrintTheReport vPrintTheReport+vUnderline+sUserID 



Would this work?

Code
Select All
var vRenameTheFile as Int

vRenameTheFile = @Shell("REN F:\Sesame\Reports\vPrintTheReport vPrintTheReport+vUnderline+sUserID") 



I'll give it a try.  In the meantime, if you see something glaringly wrong please hit me with a clue-by-four.  Thanks!
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: UserID attached to report filenames?
Reply #5 - Jan 30th, 2008 at 8:20pm
Print Post Print Post  
Hello Scott,

I'm pretty certain the filename returned by @PrintAReport includes the .htm file extenstion. So you'll need to cat the user id into the name before then.

Also
Code
Select All
vRenameTheFile = @Shell("REN F:\Sesame\Reports\vPrintTheReport vPrintTheReport+vUnderline+sUserID") 



Will rename a file named "vPrintTheReport" to be "vPrintTheReport+vUnderline+sUserID" as it is all in quotes those are literals and not variables.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: UserID attached to report filenames?
Reply #6 - Jan 30th, 2008 at 8:21pm
Print Post Print Post  
D'oh!

Trying this:
Code
Select All
// Prints the Over 30 Days by Customer report

Var vPrintTheReport as string

// Testing file rename procedure
Var vUnderline as String
var vRenameTheFile as Int
// Testing

IF NOT @Mode() = 0
THEN
	{
	vPrintTheReport = @PrintAReport(". Over 30 Days, sorted by Customer", REPORT_MODE_HTML_PREVIEW, PRINT_ORIENTATION_PORTRAIT, 0, -1, -1, -1, -1, -1, -1)
	}
ELSE @MSGBOX("This Report can only be run in Update mode",
		"Please switch to Search/Update and try again",
		"")

// Testing file rename procedure
vUnderline = "_"

vRenameTheFile = @Shell("REN F:\Sesame\Reports\vPrintTheReport F:\Sesame\Reports\sUserID+vUnderline+vPrintTheReport")
//Testing
 



The command box flashes by pretty quickly, but I think it's telling me "cannot find file specified".
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: UserID attached to report filenames?
Reply #7 - Jan 30th, 2008 at 8:26pm
Print Post Print Post  
Scott,

There's a lot you need to adjust.

1. @PrintAReport returns the full path.
2. If you add the UserID onto the end, you will mess up the extension.

Try adjusting this to your needs:

Code
Select All
var vReport as String
var vTemp as String
var vFilename as String
var vNewFilename as String
var vPos as Int
var vShell as Int

	vReport = @PrintAReport("emy", 1, 1, 0, -1, -1, -1, -1, -1, -1)

	// Get just the filename off the full path
	vTemp = @ReplLas(vReport, "\", "^")
	vPos = @Instr(vTemp, "^")
	vFilename = @Mid(vTemp, vPos + 1, @Len(vTemp) - vPos)

	// Make the new filename
	vNewFilename = @UserID + "_" + vFilename

	// Issue the rename command
	vShell = @Shell("REN " + @Chr(34) + vReport + @Chr(34) + " " + @Chr(34) + vNewFilename + @Chr(34))

 

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: UserID attached to report filenames?
Reply #8 - Jan 30th, 2008 at 8:41pm
Print Post Print Post  
Erika,

That works like a champ!  I'm going to have to study it for a while to understand what you've done, dissecting the filename and all that, but thank you so much!

My next goal is to make it a subroutine.  WOO HOO!

Would using CreateAProcess instead of @Shell eliminate the flash of the command window?
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: UserID attached to report filenames?
Reply #9 - Jan 30th, 2008 at 8:49pm
Print Post Print Post  
Infinity wrote on Jan 30th, 2008 at 8:41pm:
Would using CreateAProcess instead of @Shell eliminate the flash of the command window?


I believe so. However, since REN is built into the command shell, you need to call cmd itself with the /C switch. Like this:

Code
Select All
CreateAProcess("CMD /C REN " + @Chr(34) + vReport + @Chr(34) + " " + @Chr(34) + vNewFilename + @Chr(34)) 

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: UserID attached to report filenames?
Reply #10 - Jan 30th, 2008 at 9:21pm
Print Post Print Post  
Nope, still flashes, but that's OK as it's very quick.  I can live with it, and I'll go back to using @Shell.

It's resisting my attempts at a functioning subroutine, however.  I think it has something to do with the variables.  Still working on it.
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: UserID attached to report filenames?
Reply #11 - Jan 30th, 2008 at 9:28pm
Print Post Print Post  
Infinity wrote on Jan 30th, 2008 at 9:21pm:
Nope, still flashes, but that's OK as it's very quick.  I can live with it, and I'll go back to using @Shell.

In this case, you are using the cmd process itself, so it is going to make a shell window flash no matter what.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: UserID attached to report filenames?
Reply #12 - Jan 30th, 2008 at 9:32pm
Print Post Print Post  
Yep.  Thanks for your help.  I'm going to work on the subroutine some more tomorrow.  If I can get it to work I'll tag it onto all my report-generating buttons.
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] UserID attached to report filenames?
Reply #13 - Feb 5th, 2008 at 2:38pm
Print Post Print Post  
Well, I'm stumped as to how to make this a functional subroutine.  I've declared the variables in both the subroutine code and in the element code, but it just doesn't want to work.  Any idea what I'm missing?
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] UserID attached to report filenames?
Reply #14 - Feb 5th, 2008 at 2:45pm
Print Post Print Post  
Infinity wrote on Feb 5th, 2008 at 2:38pm:
Well, I'm stumped as to how to make this a functional subroutine.  I've declared the variables in both the subroutine code and in the element code, but it just doesn't want to work.  Any idea what I'm missing?

Not without seeing what you've got. Can you show me the code?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] UserID attached to report filenames?
Reply #15 - Feb 5th, 2008 at 3:07pm
Print Post Print Post  
This code works beautifully in the element programming:
Code
Select All
// Prints the Over 30 Days by Customer report

var vPrintTheReport as String
var vTemp as String
var vFilename as String
var vNewFilename as String
var vPos as Int
var vShell as Int


IF NOT @Mode() = 0
THEN
	{
	vPrintTheReport = @PrintAReport(". Over 30 Days, sorted by Customer", REPORT_MODE_HTML_PREVIEW, PRINT_ORIENTATION_PORTRAIT, 0, -1, -1, -1, -1, -1, -1)
	}
ELSE @MSGBOX("This Report can only be run in Update mode",
		"Please switch to Search/Update and try again",
		"")


// File rename procedure
	// Get just the filename off the full path
	vTemp = @ReplLas(vPrintTheReport, "\", "^")
	vPos = @Instr(vTemp, "^")
	vFilename = @Mid(vTemp, vPos + 1, @Len(vTemp) - vPos)

	// Make the new filename
	vNewFilename = @UserID + "_" + vFilename

	// Issue the rename command
	vShell = @Shell("REN " + @Chr(34) + vPrintTheReport + @Chr(34) + " " + @Chr(34) + vNewFilename + @Chr(34)) 



I've messed around with numerous permutations, but what I started with was putting this in Global code:
Code
Select All
SUBROUTINE ChangeReportFilename()
var vPrintTheReport as String
var vTemp as String
var vFilename as String
var vNewFilename as String
var vPos as Int
var vShell as Int

	// Get just the filename off the full path
	vTemp = @ReplLas(vPrintTheReport, "\", "^")
	vPos = @Instr(vTemp, "^")
	vFilename = @Mid(vTemp, vPos + 1, @Len(vTemp) - vPos)

	// Make the new filename
	vNewFilename = @UserID + "_" + vFilename

	// Issue the rename command
	vShell = @Shell("REN " + @Chr(34) + vPrintTheReport + @Chr(34) + " " + @Chr(34) + vNewFilename + @Chr(34))
END SUBROUTINE 


And changing the element code to
Code
Select All
// Prints the Over 30 Days by Customer report

var vPrintTheReport as String
var vTemp as String
var vFilename as String
var vNewFilename as String
var vPos as Int
var vShell as Int



IF NOT @Mode() = 0
THEN
	{
	vPrintTheReport = @PrintAReport(". Over 30 Days, sorted by Customer", REPORT_MODE_HTML_PREVIEW, PRINT_ORIENTATION_PORTRAIT, 0, -1, -1, -1, -1, -1, -1)
	}
ELSE @MSGBOX("This Report can only be run in Update mode",
		"Please switch to Search/Update and try again",
		"")


ChangeReportFilename() 


  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] UserID attached to report filenames?
Reply #16 - Feb 5th, 2008 at 3:34pm
Print Post Print Post  
Scott,

You've got a scope problem. You need to pass the filename into the subroutine. Try something like this:

GLOBAL CODE
Code
Select All
SUBROUTINE ChangeReportFilename(vFilenameIn as String)
var vTemp as String
var vNewFilename as String
var vFilename as String
var vPos as Int
var vShell as Int

	// Get just the filename off the full path
	vTemp = @ReplLas(vFilenameIn, "\", "^")
	vPos = @Instr(vTemp, "^")
	vFilename = @Mid(vTemp, vPos + 1, @Len(vTemp) - vPos)

	// Make the new filename
	vNewFilename = @UserID + "_" + vFilename

	// Issue the rename command
	vShell = @Shell("REN " + @Chr(34) + vFilenameIn + @Chr(34) + " " + @Chr(34) + vNewFilename + @Chr(34))

END SUBROUTINE 



Element Code:
Code
Select All
// Prints the Over 30 Days by Customer report
var vPrintTheReport as String

	IF NOT @Mode() = 0 THEN
	{
		vPrintTheReport = @PrintAReport(". Over 30 Days, sorted by Customer", REPORT_MODE_HTML_PREVIEW, PRINT_ORIENTATION_PORTRAIT, 0, -1, -1, -1, -1, -1, -1)
		ChangeReportFilename(vPrintTheReport)
	}
	ELSE
	{
		@MSGBOX("This Report can only be run in Update mode", "Please switch to Search/Update and try again", "")
	}
 

  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] UserID attached to report filenames?
Reply #17 - Feb 5th, 2008 at 3:43pm
Print Post Print Post  
Marvelous, thank you so much.  I knew it was something like that, because I could see that the element programming was creating vPrintTheReport but the subroutine had no way of knowing what it was.  Writeln() tests kept coming up blank.  I had no idea you could pass the info back into the code that way, thanks for teaching me new stuff!!
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] UserID attached to report filenames?
Reply #18 - Feb 5th, 2008 at 3:45pm
Print Post Print Post  
Infinity wrote on Feb 5th, 2008 at 3:43pm:
I had no idea you could pass the info back into the code that way, thanks for teaching me new stuff!!

Time for me to schedule an Advanced Programming class in Boston?  Wink
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] UserID attached to report filenames?
Reply #19 - Feb 5th, 2008 at 3:52pm
Print Post Print Post  
I would jump at it!  I'm woefully deficient on stuff like subroutines, functions, arrays, result sets, and global values.  Just tell me where and when.
  

**
Captain Infinity
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: [Solved] UserID attached to report filenames?
Reply #20 - Feb 5th, 2008 at 4:06pm
Print Post Print Post  
Infinity wrote on Feb 5th, 2008 at 3:52pm:
I would jump at it!  I'm woefully deficient on stuff like subroutines, functions, arrays, result sets, and global values.  Just tell me where and when.

It's a two day class at $350 per day and I'd need at least four people to cover the various expenses. Got three more people?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] UserID attached to report filenames?
Reply #21 - Feb 6th, 2008 at 12:58pm
Print Post Print Post  
Quote:
It's a two day class at $350 per day and I'd need at least four people to cover the various expenses. Got three more people?

Not on me at the moment, sorry.  Undecided


In re: the process we've been dealing with above (renaming report files with user names attached) for anyone else considering this who may be reading:  if the user's browser is not open before running the report, it will fail to display when the browser does open, because, of course, the file has been renamed in the meantime and the browser cannot find what it's been told to open.

I'm trying to figure out a way, now, to process the report, rename it, and then display it in the browser.  I'm also considering submitting a feature request to Lantica for a way to automate all this.  Maybe an extra switch added to @PrintAReport allowing one to tag on a value or the contents of an element to a report name?  I can think of lots of uses for this, as the monkey-mass of reports in my Reports folder are just gibberish right now, though some of them could be significant and worth saving for repeated viewing if they were tagged in certain ways.
  

**
Captain Infinity
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: [Solved] UserID attached to report filenames?
Reply #22 - Feb 6th, 2008 at 3:05pm
Print Post Print Post  
Infinity wrote on Feb 6th, 2008 at 12:58pm:
I'm trying to figure out a way, now, to process the report, rename it, and then display it in the browser.

Why couldn't you use @AsynchShell(vNewFilename) at the end of the ChangeReportFilename subroutine?

EDIT:
I just noticed that vNewFilename doesn't contain the full path, so you may need to tag the path to the front of vNewFilename before using it in @AsynchShell().
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: [Solved] UserID attached to report filenames?
Reply #23 - Feb 6th, 2008 at 5:10pm
Print Post Print Post  
Version 2.0.6 will make Carl's suggestion a bit easier.

I just added another Mode to @PrintAReport() and @XResultSetPrintReport() that creates the HTML report but does not print it or display it. It just creates it and returns the name of the file. So you can re-name it and display it in your case. or E-mail it, or FTP it automatically or any number of things that you can think of.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] UserID attached to report filenames?
Reply #24 - Feb 6th, 2008 at 6:23pm
Print Post Print Post  
That sounds great Ray, thanks.  And thanks to Carl, too, your suggestion was precisely what I had in mind to try, although (until Ray tinkered with it) I couldn't think of a way to suppress the initial report presentation.
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: [Solved] UserID attached to report filenames?
Reply #25 - Feb 11th, 2008 at 6:35pm
Print Post Print Post  
Ray, about the Mode change you made, if I want to rename the file will I still need to open a shell window?  If not is there, or could there be, a way to manipulate the filename before it is saved to disk (thereby eliminating the shell window)?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: [Solved] UserID attached to report filenames?
Reply #26 - Feb 11th, 2008 at 7:13pm
Print Post Print Post  
Hello Scott,

Yes you will still need to use a shell window to rename the file.

The change I made to 2.0.6 was simply to add another mode to the 4 that were already there. So now the options for Mode are

Code
Select All
#define REPORT_MODE_HTML		0
#define REPORT_MODE_HTML_PREVIEW	1
#define REPORT_MODE_PRINT_ONLY		2
#define REPORT_MODE_PRINT_ONLY_PREVIEW	3
#define REPORT_MODE_HTML_GENERATE	4 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged