LotusScript - How to call JavaScript script library function from LotusScript Agent? - lotus-domino

I have a LotusScript Agent that will import a CSV file and update one field value for thousands of documents. Once the field is updated and document is saved, I want to call a JavaScript script library function that in turn calls an API and perform some function in another application. How can I call a JavaScript script library function from LotusScript Agent ?

JavaScript? I assume Server-Side JavaScript, in XPages. The only way to “call” such a function is using a URL to an XPage or XAgent that runs the library function.
Or did you have something else in mind?
An alternative would be to send the other application an e-mail…

A JavaScript library within the HCL Domino Designer
allows you to store JavaScript classes, functions, and variables for common use within a HCL Domino XPages application. A HCL Domino JavaScript library is either a XPages client library or a XPages server library.
Within an XPage you would call that function, for example inside a button, like this:
<xp:button value="create" id="button1">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:import JSDemoLib;
demoprint("Hello World!")}]]></xp:this.action>
</xp:eventHandler>
You can't call/import a HCL Domino Designer JavaScript Library from within a LotusScript agent directly. That is only possible for LotusScript libraries.
Your agent would have to do a http request to a Domino server running a XPage application using the JavaScript library in question in order to execute the code contained within the JavaScript library.

Related

Handle Client side actions through JMeter (NOT through Selenium integration)

The Web Application having a list of features(Client-side actions) and These features are not captured, when I record through Jmeter/Blazemeter (NON-API (NON-HTTP) kinds of Stuff). These actions are handled through Javascript functions and .js file is not displayed in Network Tab.
So, I created the selenium scripts and integrated them with Jmeter. When I run the scripts it opens many browser instances(Headless) and performance stats get impacted.
I have to run this script with 5000 Threads. So Opening up so many browser instances is not an appropriate approach.
How to handle the client-side actions through JMeter?
As per JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
So you need to figure out what this "client JavaScript" code is doing and replicate this functionality by:
either using a suitable JMeter Plugin
or writing your own JMeter Plugin
or simulating this client-side JavaScript using JSR223 Test Elements and Groovy language

Cumulocity File Repository

I am trying to load a csv file in the Cumulocity -> Administration - > Management - > File Repository. My objective is to access the file contents in the HTML widget and show the data in tabular or chart format.
I tried using the fetch() method to use csv file url , but it was not able to fetch the file. The file I believe has been locally stored into the Cumulocity platform now. How can I access the file via fetch().
You are trying to abuse the HTML widget for something it wasn't designed for.
Instead of hacking such logic into the HTML widget you should just extend the Cockpit application with your own widget which is honestly not much more difficult using the WebSDK. https://cumulocity.com/guides/web/introduction/
There is a XSRF protection to prevent exactly what you are currently trying: Bringing in custom javascript code into the live application and trying to access the platform API by "hijacking" the cookies of the logged in user (and you would either need the cookies or hardcode some credentials as you cannot access the API unauthenticated).
If you use the SDK there is even a proper Angular service in order to fetch the file for the API.

OData REST API for integrating MS Office

I need to open office documents from my Sensenet client application. My client application is in ReactJs and I need to invoke the document to open in MS office. Is there any OData REST API available for doing the same. Kindly help.
You have two options:
1. open a file in a desktop MS Office application
There is an action in sensenet that gives you the url for that. First, get the actions for a document, using a request like this:
https://example.com/odata.svc/Root/Content/myworkspace/Document_Library('abcdef.docx')/Actions
You'll get the list of available actions, which is a JSON array containing action properties, for example a url. Look for the action named EditInMicrosoftOffice. If you display the URL of that action and the users clicks on that link, the browser should open the appropriate desktop office app (e.g. Word). You may notice that the format of the url is special (something like ms-word:ofe|u|https://example.com/Root/...). Please do not try to assemble this url manually, use the one that sensenet generated for you.
2. open and edit a file in the browser
This requires Office Online Server to be installed and configured in your environment, and you also need to display an html containing an iFrame that'll display the editor.
A simple host page:
https://wopi.readthedocs.io/en/latest/hostpage.html#host-page
Geting data to display the host page:
https://example.com/odata.svc/Root/Content/myworkspace/Document_Library('abcdef.docx')/GetWopiData

upload the html page into custom page of CA Agile rally through code

Is there any way to upload the Html page into custom page of CA Agile rally through code instead of manually doing it, through Web apis.
There is currently no fully supported way to do this via the API. There are private endpoints in the product which could technically be used for this but there is no guarantee their paths or arguments will not change.
If you'd like to explore doing this you can inspect the network tab in your browser when you create a new page (/slm/wt/new.sp) and when you add a custom html app to it (/slm/dashboard/addpanel.sp) and when you edit the settings with your code (/slm/dashboard/changepanelsettings.sp)

Access to calendar from gwt

Is there a way to write in the standard calendar from the smartphone from my gwt application.
Which that I can make a new entry in the calendar from the gwt application.
If you have a native application that you GWT application is running inside, then the easiest way would be to expose a native class to GWT via javascript injection.
For example with Android, your GWT application would run inside a WebView with a Browser instance. This browser can provide methods to you GWT application like this:
myWebView = (WebView) findViewById(R.id.web_view);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.addJavascriptInterface(new GwtJavaJSImpl(), "injected");
The methods in GwtJavaJSImpl would then be accessible from GWT by calling the JavaScript method injected.methodXxx() like this:
public native void callInjectedMethodXxx() /*-{
$injected.methodXxx()
}-*/;
If you don't have a native application on your smartphone, you could generate a calendar file (e.g. event.ics) which you then could let the smartphone download. That file would then be automatically added to the device's calendar.