View is a search result - lotus

Is there a way to determine that UI view show search results?
better to use LotusScript...
I just need to prevent users from doing specific actions to the documents selected in search results view.
Thanks

A view can not be programmatically set to only show search results. This task is usually achieved by using a "SPOFU"- Folder (Shared, Private on First use) and put the search results in there with your Code. There are a lot of things to consider when doing such code, therefor I only add a script snippet on how it would look:
Dim ses as New NotesSession
Dim db as NotesDatabase
Dim dc as NotesDocumentCollection
Set dc = db.FtSearch(...
Call dc.PutAllInfolder( "SearchResults" )
This code is not tested, and it does not provide a way to empty the folder before the search and to open the folder after successfull search, but it should give an idea...

Related

XPage view control search not working

I am new to domino designer and I am required to develop an application with it. I have went through some tutorials and I am stuck at the search function. I have followed guides I found but the search function in view control is not functioning. When I input anything into the search string(even static value), I get a server error 500. The error code is not very useful for solving my problem.(I have the full text index enabled.)
I tried to create my forms and views with the SiteFinderDemo template. I do not get an error but any search string returns 0 results.
I can modify the SiteFinderFinal's codes to work the way I want properly with the demo documents, but the search function else where just cannot work.
I also noticed new documents created with forms or xpages within the SiteFinderDemo instead of the agent do not work with the search function. I assume it has something to do with the full text searching, but I cannot find any information about it. What am I supposed to set up my application so that the search in view control can work without the server error, and what should I do to make new documents work with the search?
Thank you very much and sorry for such a long question.

To get no. of buttons on Google homepage using Static descriptive programming in QTP

I wanted to count no. of objects on Google homepage using static programming, i mean without creating object first(the way we do in dynamic one).
Pls tell me what is wrong in below statement
Set P = Browser("creationtime:=0").page("title:=Google").WebButton("type:=submit","html tag:=INPUT")
MsgBox P.Count()
Pls help, screenshot of error is attached here.
Thanks
You can get the total number of buttons by using descriptive approach.
Set odesc = description.Create()
odesc("micclass").value="WebButton"
Set i = Browser("creationtime:=0").Page("title:=Google").ChildObjects(odesc)
Msgbox i.Count()
Set i = Nothing : Set odesc = Nothing
You are actually trying to get a count of the child webbutton objects on that page object. With the original code that you posted, if there is more than one webbutton object on the page with the descriptors you're using, QTP will throw a multiple object matches found error.
Nelly's code regarding the description property is what you're after. If you are specifically looking for the count of all webbutton objects with a type:=submit, you can add additional description properties:
odesc("micclass").value="WebButton"
odesc("type").value="submit"
doing this will filter out buttons that don't have the matching type value

Storing Excel templates in my Access database

What I want:
I am working with an MS Access database to produce a report for the Ontario Professional Engineering University Accreditation board. The PEO have their templates in MS Excel and I MUST use their exact format.
I want to output the data from the Access DB to the Excel sheet (easy enough), but I want to copy their formatting when producing a new file. (I do NOT want to keep an empty template file and copy it each time).
So essentially I'm looking to somehow store the template in code. (Other suggestions are welcome!)
What I've tried:
Some of you will read this and think i'm an idiot. But what i tried was to get the data from excel on the MS Clipboard through the API Code and store the DataObject as (i was hoping) some sort of string.
But i could not preserve the formatting or cell shading from the original MS Excel template.
Any suggestions?...
You could store the Excel template(s) within the database by creating a table that includes an Attachment field
creating a record and saving the Excel template as an attachment to that record
and then using VBA code like this to save a new copy of the Excel document to disk whenever you need one:
Option Compare Database
Option Explicit
Public Sub SaveReportTemplateToFile()
Dim cdb As DAO.Database, rowRst As DAO.Recordset, attachRst As DAO.Recordset2, attachField As DAO.Field2
Set cdb = CurrentDb
Set rowRst = cdb.OpenRecordset("SELECT TemplateFile FROM ReportTemplates WHERE ID=1")
Set attachRst = rowRst.Fields("TemplateFile").Value
Set attachField = attachRst.Fields("FileData")
attachField.SaveToFile "C:\Users\Gord\Desktop\" & attachRst.Fields("FileName").Value
Set attachField = Nothing
attachRst.Close
Set attachRst = Nothing
rowRst.Close
Set rowRst = Nothing
Set cdb = Nothing
End Sub
What you are going to have to do is first export all the data into a new sheet of an empty template, then link all the data to the correct place on the template and then remove the sheet with all the data, keeping the data on the template.
As far as I know there is no quicker way to do this, but here is an example: http://www.rogersaccesslibrary.com/forum/topic350.html
It will be quite a job, but doable, if the template is well setup.

Changing Views in a Module pops me into the Admin Skin

This question has probably been the most covered question in all of DotNetNuke's lifetime but I'm going to ask it here in StackOverflow because I need an answer, a really good one that doesn't make me look the other way. Thanks in advance to all DNN experts.
I've researched many ways of making this work for me and i've seen Michael Washington's solutions (Panels, MultiViews, ...) and Will's (Strohl) blog post on DotNetNuke's personalization engine through setting SkinSrc which is useful, as well as reading through Default.aspx's code which has given me more insight, however, i'm still faced with the problem that calling EditUrl()/NavigateUrl() brings me to a page with a single module in admin skin or a page with nothing respectively.
The specific version is DotNetNuke 6.0.1 (DNN). This Module has 4 other views in addition to the main view which I desire to navigate through sequentially. e.g.
Begin Checkout -> Collection of Delivery Details -> Confim Order
Have you found a solution?
I want to achieve
1) Module loads with other modules around. No module isolation
2) Views in a module that don't Preload e.g. Page_Load in each view gets called when the Module loads up
Help!
Assuming you are asking this as the module developer, the solution is to not use DNN's mechanism for specifying a control. So, you can't use EditUrl or specify the ControlKey in the NavigateURL call (which both generate "ctl=mycontrol" in the URL). Instead you need to have your module display your various controls based on the Query String parameters. So, you'll generally have a control in your module who's primary purpose is to dynamically load other controls based on the query string. So, for instance:
You will start with your control that lists items. You'll have a "Buy Now" button for each item. The hyperlink for each item can be generated by calling
NavigateURL(TabID, "", "View=BeginCheckout", "itemid=" & id, "mid=" & mid)
2.) On the page load of the handler control, it looks to see if anything is specified for the "View" Querystring parameter. If not it displays the listing control, if so, it displays the corresponding control.
Dim controlPath As String
Dim path as String = "~/DesktopModules/MyModule/Controls"
Select Case Request("View")
Case "BeginCheckout"
ControlPath = path + "BeginCheckout.ascx"
Case "DeliveryDetails"
ControlPath = path + "DeliveryDetails.ascx"
Case "ConfirmOrder"
ControlPath = path + "ConfirmOrder.ascx"
Case Else
ControlPath = path + "ItemList.aspx"
End Select
If System.IO.File.Exists(Request.MapPath(controlPath)) Then
placeholder.LoadControl(controlPath)
Else
Throw New Exception("Unable to load selected template. Please go into module settings and select a list and details template.")
End If
Most of the advanced modules for DNN do something along these lines so there's plenty of sample code out there. I would guess some of the core modules do something similar. I adapted the code above from Efficon's Articles module for DotNetNuke.

Easy recreation of "Shared, Desktop Private on 1st use" views

I have some views that uses #UserName in the selection formula. For working that, the view must be "Shared, Desktop Private on 1st use". That is no problem.
But this views are going to be redesigned quiet often.
As this is a bunch of views it is very uncomfortable for the user to delete each of this views to recreate from scratch with design changes.
I try different things to get that done with an agent but no one is fool-proof and give some strange results (sometimes even do not update the design).
Best result so far is to delete the icon from the workspace and open the application again. That works (until now) always. But this is so annoying for end users to reopen the app from the (deep leveled) server folders.
Any other method to update the design of "private on 1st use" views ?
As you noticed, private views are a pain to maintain. Why not go a different way to solve your problem?
Create a categorized view, where the first, categorized column contains the field you compare the username in your current solution to.
Than embed that view into a form as a "single category embedded view" and use #username as the category.
Presto. Now you have a view that only shows documents for the current user and you can change the design whenever you like.
Mick Moignard has a good article on that topic online: Dynamic view filtering in Notes.
See also the Lotus Domino Designer Help, Topic "To show a single category in embedded views"
I have tried to solve the same problem and ended up doing two things - (1) automatically send the user an email with a link to the database and ask them to remove the database icon so that the private views get deleted and (2) alert the user when the design of a private view has changed.
The first part was fairly simple - I wrote a LotusScript function that would send the current user an email message containing a link to the current database (the one that contains the private views), along with some meaningful text and database information. All the user had to do then was exit the database, remove the database icon, open the email they just received and open the database again using the link. No need to navigate the server folders or wonder which server to go to. This can be used on its own, e.g. in a button, but I ended up combining it with something a little more tricky.
The second part was devising a way to alert the user that the design of the view they are opening is outdated. The tricky part was detecting that the design of the view has changed. What made this possible was what actually caused the problem in the first place - the fact that Notes caches the private view. When caching the private view, Notes also caches constants that the script in the view events refer to, that are part of LotusScript libraries the view uses.
Here's a description of the design I used:
Let the view use shared script library, PrivateViewsCode.
In PrivateViewsCode's (Declarations) declare Const DESIGN_VERSION = "1.0".
In PrivateViewsCode declare function myQueryopen. One of the parameters myQueryopen receives is string designVersion.
In the private view's Queryopen event call myQueryopen, passing DESIGN_VERSION to designVersion. Since this code is in the view that is cached, DESIGN_VERSION will contain the constant value as it were in the moment the view design was cached (when the user first opened it), in this case - "1.0".
In myQueryopen compare designVersion to DESIGN_VERSION.
Dim designChanged As Integer
designChanged = (designVersion <> DESIGN_VERSION)
Since myQueryopen is part of PrivateViewsCode script library, here you actually compare the DESIGN_VERSION (as cached in the private view and then passed to myQueryopen) to DESIGN_VERSION from PrivateViewsCode, which is always current.
The only thing left is to be sure to recompile the views (Tools\Recompile all LotusScript) after changing DESIGN_VERSION.
I hope this explains the design, here is how it works:
After making changes to private views design you change the version:
DESIGN_VERSION = "1.1"
Recompile all LotusScript.
Refresh the database design.
Users open any private view that uses this functionality.
They get a message saying they will receive link to the database and that they have to remove the icon from the workspace and open it again using the provided link.
The user closes the database and removes the icon - private views are deleted.
The user opens the database link in the email, the next time they open one of the private views, the new design is cached along with the new value of DESIGN_VERSION (here, "1.1").
The comparison (designVersion <> DESIGN_VERSION) now yields false. Everything is back to normal until the next update.
Ken's way of handling this has the major advantage of not involving the users at all. This wasn't an option for me because of the frequency with which I made changes to the views (the application was just deployed and I had many requests for changes to the views) as well as the big number of private views in the application.
(Edit)
I assumed you had a specific reason to use private views, but I used the "Show Single Category" in an embedded view (just as leyrer suggests) ever since it became available and was quite happy with it. If you see any limitations to using the "Show Single Category" option, I'll try to help you with that.
I found a way that moves the pain from the end user to the developer. I designed the navigation to use outlines so I can control where the user goes when they navigate to a view. Notes outline entries can be changed without the user needing to go through the delete-icon-then-reopen-database hassle.
When I need to update the design of the private view, I rename it as well and also update the reference to it in the notes outline entry. At the users desktop, when they next open the database, a new private view will be created for them. Most (or all) of my users never noticed anything, at least they never mentioned it!
The process is fairly easy for the developed but also fairly easy to forget. Also, the user's workspace will end up having a lot of references to old unused private views, which if they are large in size might become a problem down the line. If you change the view twenty times, or change twenty views, for example, it may be time to delete the icon to clear them out. For me the changes were rare enough for this not to matter.
The solution to your dilemma is not too hard to solve, but a little tedious. There is a technote on simply removing private views programmatically. It is a common design issue for developers.
I have had to take the following approach to manage multiple private views which were all going through multiple versions at any one time.
The secret is to do a check on the DatabaseOpen event, as it's a view held on the local client so you need to do this through user's UI activity. As long as your Lotus Notes client fleet is at running version 6.5.x you could try the following. To be concise, I have outlined what you need to do.
Name your private view "yourPrivateViewName_1.0|yourPrivateViewName"
Note the use of an alias. This is so you can reference the view in an outline or code, no matter how many versions you use.
This can also be a multi-valued field if you have more than one private view to manage.
Create a database profile document that has a field with the current private view name, eg "youPrivateViewName_1.1"
On DatabaseOpen loop through the views, finding the private view(s) then compare the name to the one in the database profile. The naming convention is designed to make it possible to do a version check. If the versions don't match, remove the view. When the user opens that view the next time it should grab the current version you have released.
There are other ways as well, like checking the timestamps on the private view and the template, but it still requires a way to single out the private view. But I found this way easy enough to manage.
Thank you all !
I finally ended up with the following:
Create an Agent running from menus that close the database
Sub Initialize
Dim s As New NotesSession
s.SetEnvironmentVar "remove-"+s.CurrentDatabase.ReplicaID,"1"
Dim ws As New NotesUIWorkspace
ws.CurrentDatabase.Close
End Sub
In the database close event mail a database link and send keys to remove from workspace
Declare Sub keybd_event Lib "user32.dll" (Byval bVk As Integer, Byval
bScan As Integer, Byval dwFlags As Integer,Byval dwExtraInfo As Integer)
Sub Queryclose(Source As Notesuidatabase, Continue As Variant)
Dim s As New NotesSession
x = s.GetEnvironmentString("remove-"+s.CurrentDatabase.ReplicaID)
s.SetEnvironmentVar "remove-"+s.CurrentDatabase.ReplicaID,""
If x="" Then Exit Sub
Dim ws As New NotesUIWorkspace
Call ws.AddDatabase( s.CurrentDatabase.Server,s.CurrentDatabase.FilePath)
Dim m As New NotesDocument(s.CurrentDatabase)
m.From = s.CurrentDatabase.Title
m.SendTo = s.CommonUserName
m.Subject = "Link to open " + s.CurrentDatabase.Title
Dim rt As New NotesRichTextItem(m,"Body")
rt.AppendText s.CurrentDatabase.Title
rt.AppendText " -> "
rt.AppendDocLink s.CurrentDatabase,"Open Application"
m.Send False
Delete m
keybd_event &h2e,0,0,0 ' Del key down
keybd_event &h2e,0,2,0 ' Del key up
keybd_event &h0D,0,0,0 ' Y key down
keybd_event &h0D,0,2,0 ' Y key up
End Sub
(You all got your upvotes but a i mark as answer for the lowest rep. points user.)

Resources