Intermittent behavior in xpages application: by pressing the button to save, the document is not redirected and is displayed again - xpages

I'm having a problem with a new xpages application that was deployed in production for a few months, but has now only been expanded to the entire enterprise now. The problem that did not happen while the application was in production pilot is intermittent and happens when an action executes a current notesxsppdocument save (currentdocument). The symptom is that by pressing the button you save, the document is not redirected and is displayed again. What can be this problem. session timeout, a bug from xpages? The application basically uses the components of the extension library, there is no external component to the xpages. When the problem occurs, if the user closes the document's xpages opens again and then clicks the button again the code runs successfully.
I have a function that stores a file attached to the doc in a repository. I suspect she's the problem. The function uses the file upload component and a button to execute a java agent that stores the file in a repository. The button code below follows. Its function is basically to create the rich text if it does not exist and call the agent that consumes a web service to transfer the file to a repository and erase it from the document.
I asked the user not to use the function for a few days at the time of the service to verify that the problem will persist.
if(validaArquivo())
{
var url=#ReplaceSubstring(context.getUrl(),"openDocument","editDocument")
url += '&tab=dossie' ;
var fieldItem:NotesItem =
currentDocument.getDocument().getFirstItem("arquivos");
if (fieldItem==null){
// create the field as an RTF
//writeToLog("Creating xxxxx field");
var rtItem:NotesRichTextItem =
currentDocument.getDocument().createRichTextItem("arquivos");
currentDocument.save();
}else if (fieldItem.getType()==1280){
//writeToLog("--> Converting xxxxx to RTF");
currentDocument.replaceItemValue("arquivosTEXT",
fieldItem.getText());
fieldItem.remove();
var rtItem:NotesRichTextItem =
currentDocument.getDocument().createRichTextItem("arquivos");
currentDocument.save();
}
var agente:NotesAgent=database.getAgent("(SalvaAnexos)");
agente.runWithDocumentContext(currentDocument.getDocument(true));
context.redirectToPage(url)
}
else
{
document1.removeAllAttachments("arquivos");
}

When users are using the application, rebuild or to change some code on prod environment can cause this.

Related

Automatically open Office documents on a Sharepoint Server 2013 in Firefox (full Office integration)

I recently switched to Firefox. Unfortunately my company still uses Sharepoint Server 2013 (migration to Sharepoint Online is planned somewhere in the future) which no longer offers a fluid integration with Office.
Every time I want to edit an Office document, it gets downloaded instead of being 'forwarded' to be opened by Word, Excel, etc. Modifications need to be saved locally and than uploaded afterwards. This is hugely annoying.
Is there some way that I can automate this in code, using a Firefox extension? Does Sharepoint expose some kind of hook or metadata containing the document's URL?
(Self-answer originally provided by Dotsoltecti; copied from question body into a proper answer).
Sharepoint 2013 passes the document's URL via the right-click contextual menu.
There exists a very neat add-on for Firefox called "custom right-click menu" by Sander Ronde. After installing this extension I added the script below:
var feedback = crmAPI.getClickInfo();
var url = feedback.linkUrl;
if (url.endsWith("docx") || url.endsWith("doc")) { var uri = "ms-word:ofe|u|" }
if (url.endsWith("xlsx") || url.endsWith("xls")) { var uri = "ms-excel:ofe|u|" }
if (url.endsWith("pptx") || url.endsWith("ppt")) { var uri = "ms-powerpoint:ofe|u|"}
var toOpen = uri.concat(url);
window.open(toOpen);
Et voilĂ : right clicking on a Word/Excel/PowerPoint-document executes the script and correctly forwards the document to the said program (you have to whitelist your SharePoint-site with the pop-up blocker). Modifications are handled directly by the Office-program.
Only drawback so far is that every time a document is opened, a new blank window is generated. I haven't found a solution for that yet, so suggestions are always welcome.

Dynamics CRM Dialog hangs/freezes when called via script

when dialog process is called from a script that is embedded on a ribbon button, The dialog freezes and enter into a not responding state.
I just figured out that When calling the dialog via script check the ObjectId Guid that it passes. If the provided Guid does not exist on CRM Database the dialog will hang without giving any error. This may happen if you want to create a dialog that do not need a entity record to run against. In this type of case you just want an inactive record to appointed as ObjectId.
function CallDialog()
{
var clientId = Xrm.Page.context.getClientUrl();
var url = clientId + "/cs/dialog/rundialog.aspx?DialogId=%7b460ACCDC-701C-4947-8E72-CDE2C53807FC%7d&EntityName=EntityName&ObjectId=%7b115fbb02-b5a5-e711-8122-005056b32967%7d";
window.open(url,"", "width=700,height=600");
}

Google analytics stores username and password as a part of url

Issue Context:
I am using meteor js for a mobile app.
I have hooked it up with google analytics calls and basically I am using two type of calls:
Screen views
Events
Screen views are just fine, but I'm facing an issue with the events.
When I go to Behavior -> Events -> Screens, in the google analytics dashboard, I can see the URL of every page that has triggered an event under the Screen Name column. My problem is that the page URLs for my login page look something like this:
meteor.local/login?username=*******&password=+++++++&rememberMe=on
Where ******* is an actual username and +++++++ is the corresponding password!
Reason:
Since I have to share this analytics account with multiple people, I do not want this information to be available over here.
Clues:
CLUE 1:
I used to do GET http calls, but I have changed them all to POST and it still has not fixed the issue as I expected it not to pass plain parameters through URL anymore.
CLUE 2:
I've noticed that the default google analytics js framework is working with http and not https. I was wondering if it is calling the analytics server with a GET as well. If so, is there anyway to change that?
CLUE 3:
Here is how I am initiating the GA instance:
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', googleKey, 'auto');
CLUE 4:
I have also noticed that these URLs are getting captured very occasionally. E.g. in the pas 12,500 unique events (about 30,000 total events) it has captured just 9 URLs with the username and password. The remaining 12,491 events have
meteor.local/login
OR
meteor.local/--
OR
localhost/--
as the Screen Name.
CLUE 5:
I have also put 4 "search and replace" global filters on the analytics account to search for this string
meteor.local/.*
and replace it with this one
meteor.local/concealedURI
This does not seem to be working either.
I have added this filter on 4 different fields (Since I still really don't know where the URLs are coming from):
Host Name
Page Title
Referral
Request URI
CLUE 6:
This is how I am calling the GA instance to send the event:
ga('send', 'event', 'button', 'click', eventName);
Okay. So, I had to run a lot of experiments and try out different things to solve this issue.
After trying all the things that I have described in the question, I finally found a way to address this problem.
The main cause of this problem was that I was using a google analytics account set to track an App, to capture the data from an app that was built with meteor js (which basically utilizes cordova).
Using meteor means that my app's screens are actually web pages rendered as a mobile app. It seems like meteor uses URLs to navigate through these screens.
On the other hand, google analytics looks at (and captures) the screen name of an app's page, when an event is triggered from that page. In native apps this screen name will be something similar to "About us", "Contact Us", "Home", etc.
Now since a meteor app is not the same, the screen name returned by meteor is actually the URL of the page that has triggered the event.
This does not have anything to do with the http calls (Whether or not they are GET or POST), because it is the local URL used by meteor for navigating that is being passed down to google analytics and not any http calls.
Solutions
1.
If I had the google analytics account set as a web page tracker, I could have access to "Exclude URL Query Parameters" field and I could potentially exclude username and password as was suggested by #Mike and #PhilipPryde in the comments.
However, I needed to use google analytics set as an app tracker. So, this did not work for me.
Failed
2.
I did put a filter on the whole view in the google analytics and searched for meteor.local/.* and replaced that with hiddenURL. The filters on
Host Name
Page Title
Referral
Request URI
did not work.
But when I put the same filter on
Screen Label
field, it worked.
However, this only looked at the screen names returned by screen view hits and not the event. Thus, this did not actually solve my issue either.
Failed
Finally, I had to do this:
There is a method call on GA instance that lets you set different options up. I ended up using this:
ga('set', 'screenName', 'hiddenURL');
This changed the screen name to "hiddenURL". So, I used this before every event and it worked for me.
My code for sending events to google analytics looked like this:
ga('set', 'screenName', 'hiddenURL');
ga('send', 'event', 'button', 'click', eventName);
PS:
This changes the screen name that was showing up in real-time reports of google analytics to "hiddenURL", whenever someone triggered an event. But, it changes back to a screen name as soon as they go to another page. So, it would not also mess with any of your screen view data either, since it is not being captured as a screen view.
Of course that is because, I pass the screen name to my GA instance every time I send a screen view. So it looks like this:
sendScreenViewToGA = function (screenName) {
ga('send', 'screenview', {
'appName': 'Something',
'screenName': screenName,
'appVersion': x.x
});
}
If I had used the screen name, that is being set on the environment tight now, I would have ended up with all my screen names in analytics set to "hiddenURL".
I really hope this post will help others with same issues and save them some time.

how to run agents in xpages from a web browser?

I got this problem and started googling about it, but no direct answer were pulled out. My query problem is, I'm doing an xpage project and I need to run an agent that uses lotusscript as a language. The agent is used to read a TSV text file and create notes document from each record there. Independently running the agent went very good, no problem. But when I tried to run it from xpage using this script :
var doc = database.createDocument();
var field = getComponent("filePath");
var agent:NotesAgent = database.getAgent("UploadTSV");
if (agent != null) {
agent.runWithDocumentContext(doc);
TSVDoc.setValue("filePath","Agent run");
}
else{
TSVDoc.setValue("filePath","Agent did not run");
}
it did not run. I'm just wondering what I did wrong. Thank you in advance.
My way to do this would be to trigger the agent (either it's based on a page load event or on a user click event) via client Javascript. The URL to run an agent is nothing more than
http://yourhost/yourapp.nsf/youagent?openagent
So I'd just make a AJAX call to that URL to run the agent. To get return values (errors of anything else) I'd add some code to the agent's print output. Print statements (in Lotusscript) in agents called from the browser produce a HTTP response. Similar for agents written in Java but there you have to do more than simple sysouts.

In an XAgent inside XPages how to redirect to a new Window?

I have this XAgent with seems to work fine but it opens it in the CURRENT browser. How would I open it in a new window?
This code is running in After RenderedResponse of an XPage.
Thanks
// Track Downloads
// Setup XAgent stuff
var exCon = facesContext.getExternalContext();
var writer = facesContext.getResponseWriter();
var response = exCon.getResponse();
var fileLink = param.get("link");
// Insert Logging Code here
facesContext.getExternalContext().redirect(fileLink);
writer.endDocument()
Looks like you are trying to track when somebody clicks on the download link.
Without tracking the link would have been pointing directly at the file causing the browser to initiate the download and the user would stay on the current page. With the XAgent tracking in place the user is going to a different page in the application to do the tracking and initiate the download.
You could add a target of '_blank' to the initial link that is calling the XAgent. This will cause a new window/tab to open in the users browser but it will close once the download initiates.
Using this method of tracking the downloads will, however, remove the ability for the user of the site to be able to right click on your download link and do a 'save as'.
For a download link you could also consider to just stream the file using the OutputStream (there only can be one: Writer or Stream!) to directly serve the bytes of the file to download. You need to set the MIME type in the header. If it is not a file type the browser can handle, the download dialog will appear anyway. Opening a new window is actually considered bad style these days. If a user wants a new Window there is Ctrl+Click and Shift+Click -> a decision you shouldn't make for them (which opens the can of worms of browser illiterate users).

Resources