LotusScript agent on click button on web and alert - lotus-domino

On my web application, I am putting all the view documents into HTML and then inserting HTML into Rich text field, this also crates button to update selected document on the form using javascript and then runs the agent to update selected documents on the web. Now in agent I am putting following code
Print |<script> alert('documents has been updated successfully');</script> |
URLtoredirect =Strrightback(query_string, "&Return=")
|
Print "[" + URLtoredirect + "]"
However if I put alert before or after this statement
Print "[" + URLtoredirect + "]"
it does not redirect to the page above instead it just prints the on the form. but if i remove alert code it works and redirects.
What would be wrong here.

A printed redirect in LotusScript only works if it is the first and only print statement in your code. That's because that type of redirect is implemented on the server side. I.e., if the first and only print statement executed by the agent starts with "[" and ends with "]", the server never sends the HTML/Javascript output to the browser. It does an internal redirect to the specified URL instead.
If you want to display a message and then do a redirect, you need to add do them both in your Javascript. I.e., something like this:
Print |<script> alert('documents has been updated successfully');location.href='| + URLtoRedirect + |');</script>|

Related

AppleScript - accentued characters

I have problem with special characters in AppleScript (service in Automator).
The selected text (title of a book) is the input (titre in the script), and the goal is to display in safari the result of the advanced research of this book on noosfere.org
It's ok when there is no accent characters in my selected text.
But if titre is sphère d'influence :
In the display box (only used for testing), "sphère d'influence" is correctly written with the "è".
But in safari, in the research field in the website, I have "sphère d''influence".
on run {titre, parameters}
set url_noosfere_titre to "https://www.noosfere.org/livres/noosearch.asp?Mots=" & titre & "&Envoyer=Envoyer&livres=livres&ModeRecherche=AND&ModeMoteur=MOTSCLEFS&recherche=1"
display dialog (url_noosfere_titre as text) buttons {"OK", "annulé"}
set retour to button returned of result
if retour is equal to "OK" then
open location url_noosfere_titre
end if
end run
URL with accents is very messy.
Basically URL's should be converted using 2 hexadecimal values with escape character '%'.For instance, "é", should be converted in %C3%A8.
However, result depends of web browser (IE, Safari, Chrome, Firefox) and versions. Sometime the browser is doing its own conversion which you can't avoid.
In your case, it is probably more efficient to change your mind and don't try to fill URL with the word you are searching for, but instead, just display the web page and set your word directly into the search area of the page, then click on the submit button ("Envoyer" in French).
In Applescript, you can manipulate a web page by using Javascript commands.
The script bellow displays your web page, add your word to search in the correct field, select the search area and submit the request by clicking on the submit button.
Doing that, no accent issue at all !
set BaseURL to "https://www.noosfere.org/livres/noosearch.asp?Mots"
set MyWord to "sphère"
tell application "Safari"
open location BaseURL
activate
delay 1 -- time to open the new window. Could be replaced by checking javascript load = complete
tell document 1
-- fill the search field of the page with expression to search
do JavaScript "document.getElementsByClassName('liste')[0].firstElementChild.children[1].value = '" & MyWord & "'"
-- check boxes for search area are 1, 3, 5,...17, 19 in "littérature" block
-- in this example, select the 2nd check box, so index is 3 (="Livres")
do JavaScript "document.getElementById('litt').children[3].click()"
-- click on the search button of the page (="Envoyer")
do JavaScript "document.getElementsByClassName('liste')[0].firstElementChild.children[2].click()"
end tell
end tell
fyi, I have been forced to add the selection of a search area (here I click on check box for all books ='Livres') because at least 1 selection in that area is mandatory.

Lotus Domino web: How to copy some of field values in current document, save it to a new document and redirect the browser to open the new document

I need help in Lotus Domino Web. In the view, Last Name is clickable. When I click on one document (Last Name = e.g, Doe), the document will open and there would be a button named "Add Guest".
Once the Add Guest button was clicked, some of the field values in current document must be copied (Date Created, Time Created, Status), copied document must be saved, and copied document MUST open using PRINT (?EditDocument) so I can add some additional details in the document.
Note that this is Web, not Client.
Screen shot of view with last name, and current document with Add Guest button.
Any help will be really appreciated.
I am assuming you have written a WebQuerySave agent using LotusScript, the DocumentContext is the variable 'context' and the copied document is the variable 'newdoc'.
After you save the new document...
print "[http://" + context.Server_Name(0) + "/" + newdoc.ParentDatabase.Filepath + "/0/" + newdoc.UniversalID + "?EditDocument]"
This must be the only print statement that executes in your agent.

VB 2010 - Button that opens DEFAULT email program and populates entries from txtboxes

I've created a form in VB that requests some entries and through those entries a body for an email is created. Now I have to make a button that opens the default email client of the computer and populates the Body with the text that is generated through the form (I don't want it to send the email since the user is supposed to add the From and the Subject). I've managed to make it happen through this simple line :
Dim Text As String = Textbox1.Text
Process.Start("mailto:email#email.com?subject=Hello&body=" & Text)
However, when the email client opens the format of the body is messed up. There are supposed to be paragraphs and spaces but there aren't any. Can you help me fix this ?
In order for MailTo to work properly, you need to URL Encode your message. The following should work:
Dim Text As String = Textbox1.Text
Process.Start("mailto:email#email.com?subject=Hello&body=" & System.Web.HttpUtility.UrlEncode(Text))

seleniumIDE - how to store a hyperlinks address and then visit that URL? Was working before

I had this working fine a couple of months ago but now when I run the test it fails and I don't know why or how to fix.
Background:
I have a screen with several links so that the 'admin' user who is currently logged in can login as one of the 'practitioners' via the login hyperlink presented.
Details:
So for my test I click on the 'Login link' hyperlink(s), enter & confirm a new password as required, and then I get to the practitioners screen 'as them'. The 'wrinkle' was that the pop-up for the user to enter their (new) password happened on a new window that the selenium IDE used was a new window. So basically just clicking on the hyperlink didn't work. To get around this I was able to store the hyperlink's href -a#href- in a selenium variable first_login_link_to and then use open instead of clickAndWait to visit the page, i.e. open ${first_login_link_to}
This was working fine a few months ago.... but it is not working now.
I get page doesn't exist and when I look at the url - urgh! It somehow includes the locator stuff and I am getting
http://dmplanning-stage.herokuapp.com//tr[td[contains(.,'6 Day')]][1]/td[8]/a#href
instead of
http://dmplanning-stage.herokuapp.com/p/zaH7m3aL7fxuPLvrc21L
in the browsers url address bar.
How can I get selenium to open the url stored in the variable and not use that 'locator' address?
selenium:
open /admin
clickAndWait link=practitioners
store //tr[td[contains(.,'6 Day')]][1]/td[8]/a#href
open ${first_login_link_to}
Found it - whew! Somehow my storeAttribute got changed to plain store.
Once I changed it back everything worked again!
This one worked for me
1-
Command = Store
Target = stuff you want to paste
Value = Var
2-
Command = sendkeys
Target = id for area where u wana paste
Value = ${Var}
3-
Command = Fireevent
Target = id for area where u wanna paste
Value = paste

How to check all the links dynamically?

The following thing I have to do using VBScript in QTP 10/11:
The VBScript opens one login page. After the login it counts the number of links in that page and then prints all the links. Afterwards it opens every link one by one.
I am having issues with finding all the dynamic links.
You can get all the links on a page by using the Page's (or Frame's) ChildObject method.
Set desc = Description.Create()
desc("html tag").Value = "a"
Set links = Browser("B").Page("P").ChildObjects(desc)
For i = 0 to links.Count - 1
Print links(i).GetRoProperty("inner_text") & " => " & links(i).GetRoProperty("href")
Next
As for clicking them, that's a bit more complicated since after clicking a link you cause a navigation that invalidates the links object, you should either perform the ChildObjects each time (while keeping track of the index) or open the links in a different browser/tab.