Blue Prism: Cannot Iterate through JSON items withing injected JS script - javascript

So I am trying to iterate through JSON items via injected script. And BP is throwing me a syntax error that it is incapable of compiling my code.
code:
function fillInputs(json){
alert(json[0].Email);
}
through Invoke I am giving [JSON] variable that has a well structured JSON object which I created with help of Utility - JSON and it is working fine on test websites. But BP will not initialize specifically this part / alert(json[0].Email); / and is throwing a standard error which usually means syntax errors.
Could someone tell me if there is a better way to iterate through JSON objects with Blue Prism injected Javascript code and if I am choosing a harsh way to do it?

This is easily accomplished using the built-in Internet Explorer browser automation features provided out of the box in Blue Prism.
For organization, place your custom Javascript in a data item of type text on your action page:
Then use a Navigate stage to insert the fragment and invoke it:
With your current snippet, you'll get a nice alert window in Internet Explorer:
A good way to retrieve this data using Blue Prism would be to use the Javascript snippet you insert to create a hidden input element, the value of which is set a string representation of the JSON data you're attempting to exfiltrate.
You can then create a manual Application Modeler entry based off of an existing one to target this hidden element, and then use a Read stage to copy the data into a Data Item within Blue Prism. Further, you can use the bundled JSON object (or write your own as a wrapper around a better VB/C# library) to extract and manipulate the data within as you wish.

Related

Using JS Object Based Multidimensional Arrays to Collect, Store, and View Data in a PDF Form

I have an interactive PDF form created in Acrobat that employs a multidimensional object to collect, store, and populate form fields used to view the data. The form serves as a password manager to view individual password records whereby I have recently completed the lookup record page view that works like a charm. The only issue I've run into thus far is my inability to delete a record selected in the lookup view in which event I initially thought I'd be able to use the JS array.splice() method to simply delete a line item in the object array that stores the data for the particular record I want to delete. Come to learn that the script used to create the object that stores the data still remains inside the form whereby literally nothing has changed. Upon further study, I am inclined to believe that the form is essentially serving as a window to view the information stored in the object and for whatever reason invoking a script using the JS slice() method has no effect whatsoever on the script that created the object to begin with. Hence, in order to make this work, it appears I need to be able to rewrite/replace the script minus the object property/s that hold the data for the record to be deleted. Sorry for the novel. Any comments or suggestions regarding this subject matter are most appreciated. Thank you ahead of time.
Created a script using the JS splice() method in a futile attempt to remove data from an object used to collect and store data inside an interactive PDF form.
From Adobe's Docs:
You can use the Document JavaScript dialog box to add, edit, or delete scripts in your current document.
To open the dialog box, choose Tools > JavaScript > Document JavaScript.
Here https://helpx.adobe.com/uk/acrobat/using/add-debug-javascript.html
I've never used Adobe Acrobat, but if you need to edit a script in a PDF, that's probably where to get at it.
If you post the script's code, someone might be able to help you. It's almost impossible to get an answer to any question without posting code.
I apologize regarding my initial post as I knew little to nothing at the time regarding how to create and use an object literal in which event I have since learned how to use an object literal along with its methods to add, delete, and edit key-value pairs of an object literal. I was then able to resolve all my issues in using an Acrobat PDF form as a front end along with a hidden text field using JSON to convert a JS data object for organizing and storing my form data as a string. The script to accomplish this task is as follows:
dsFld =getField("dataSrc");// call getField method used to obtain the
stored JS object as a JSON string
oVendors = JSON.parse(dsFld.value);//Parse the JSON string to manipulate
the JS data object
btnDel=getField("btn.del");
var oFld;// create var oFld for later use
var oPassData = oVendors[event.value];
if(oPassData){// script to populate PDF form fields
//walk members to fill fields
for(var nNm in oPassData){
// skip fields that don't exist on form
oFld = this.getField("inf." + nNm);
if(oFld)
oFld.value = oPassData[nNm];// script to populate associated form
fields
}
In looking back, I am sorry for any inconvenience posed by my initial post.

how to parse web page contents in android with js using jsoup

How can i parse HTML page in Android with js results? The main problem is that if i simply use Jsoup.connect() method the Document object doesn't contain js results, because js needs some time for running. Is it possible to delay connection?
As already mentioned in the comments, JSOUP does not run any JavaScript. For that you would need a JavaScript Interpreter.
Since you mentioned that the page you are wanting to read takes some time to render, it seems clear that you actually need to run the JavaScript to render the DOM.
However, if you look into the source code of the page you may be able to figure out how the JavaScript actually renders the page. I see two possibilities:
1) The JavaScript really just runs to dynamically render the page with information that is already loaded with the initial access. That frequently happens for modern websites that are able to send along all relevant data with the first access (aka isomorphic rendering). Here you may get the wanted information for data that is usually available in the website as JSON objects. You can extract the JSON and then parse this with a JSON parser.
2) The JavaScript actually loads some data asynchronously. IN that case you can identify these http requests and use JSOUP to get this data. Usually such data is in JSON format, so also in this case it may make sense to use A JSON parser to read out the relevant parts.

Access to filesystem with javascript in a QWebview

I have a to do a game launcher.
I use a QWebview initialized in c++ and I use javascript / Html to build my menus.
I want to execute a binary in filesystem when I click on a button.
Is it possible ? I didn't find any solution.
You can use QWebFrame::addToJavaScriptWindowObject() to make a C++ object visible from Javascript code in your page.
Create a C++ object and add a slot to that object that uses QProcess to start the binary you want. Make it visible calling addToJavaScriptWindowObject(). Now you can call the slot from javascript code and pass the path to the binary in it.

Adjust static value into dynamic (javascript) value possible in Sharepoint allitems.aspx page?

<SharePoint:SPDataSource runat="server" IncludeHidden="true" SelectCommand="<View><Query><OrderBy><FieldRef Name="EventDate"/></OrderBy><Where><Contains><FieldRef Name="lawyer_x0020_1"/><Value Type="Note">F. Sanches</Value></Contains></Where></Query></View>" id="datasource1" DataSourceMode="List" UseInternalName="true"><InsertParameters><asp:Parameter DefaultValue="{ANUMBER}" Name="ListID"></asp:Parameter>
SharePoint WSS 3.0
This codeline is just one line of the allitems.aspx of a sharepoint list item (SharePoint created it himself). It only displays items where lawyer 1 = F. Sanches. Before I start messing around with the .ASPX page I wonder if it possible to change F. Sanches (in the code) into a dynamical variable (from a javascript value or something else that can be used to place the javascript value in there dynamically). If I put any javascript code in the line it will not work.
P.S. Ignore ANUMBER part in code.
Let say to make it simple I have javascript variable like this (now static but with my other code it is dynamic). It would be an achievement if it would place a static javascript variable.
<SCRIPT type=text/javascript>javaVAR = "P. Janssen";</script>
Eventually I would like to filter with OR operator
If Yes --> how?
If No --> Thank you!
The easiest way to add a filter to a standard list view is to use query string filters - add
?FilterField1=Lawyer&FilterValue1=F. Sanches
to the url. If you are working with a note field, it probably won't work directly, but you may find it easier to set up a field that does work than to make the server side chages you would need to modify the query directly.
Another approach that might work would be adding filter web parts to the page - I haven't worked with those much myself, but in theory they should be able to do what you want.
I don't think JavaScript will work since JavaScript is client side and SPDataSource is server side.
However, you should be able to use a control via ControlParameter. There are good examples here and here. Once the parameters are working, OR operators will definitely be supported within the CAML of the SelectCommand.

Including Information in HTML for Javascript to Consume?

I'm am building a web app with app engine (java) and GWT, although I think my problem is moreso a general javascript question.
In my application, I want to include a side-menu which is generated from data in my database. This obviously needs to be done dynamically from a servlet.
Currently, I am sending a blank menu container, then making an ajax call to get the information i need to populate the menu. I would rather just send the menu information along in the original request, so I do not need to waste time making a second request. I used this initial approach because it seemed simpler: I just wrote a gwt rpc service that grabbed the data i needed.
My question is, can I instruct a javascript library like gwt to look for its information in the current web page? Do I have to hide this information in my original HTML response, maybe in a hidden div or something?
If the data that you'd like to embed is restricted to menu items, why not directly generate lightweight HTML out of simple <ol> and <li> elements? You can still keep HTML out of your Java code by using a template engine. The menu markup could just be styled with CSS or if you need something fancier than mere <ol> and <li> elements, you can massage the DOM with JavaScript once the page loads (read: progressive enhancement).
If you're looking for a more generic solution, beyond the menu case, then you could embed a JSON block in your page, to be consumed when the page loads for the dynamic generation of your menu.
Or, you could look into using a microformat that is suitable for menu data.
You can include a script block in the original response defining the data and then use an onload event (or similar) to create the menu based on that data; that's very similar to what you're doing now, but without the extra trip to the server. I'm assuming there that the data to construct the menu is transformed in some way by JavaScript on the client; otherwise, just include the menu markup directly.
GWT has something called JSNI (Javascript Native Interface) that can interface with other non-GWT Javascript. So, you could in your HTML page container have a containing the generated menu items as a Javascript object. Then, in your GWT code, you have a JSNI call to fetch this data and put it in the right place in your UI/DOM with GWT methods.
I asked a similar question a few weeks ago about how to store data safely inside HTML tags. It also contains a few links to other questions. Here
There are in general 2 options:
Store the data in some xml tags somewhere in the html code and later get the information from there by traversing through the DOM. (you can hide them with css)
Store the data as JSON data in a script tag. (There en- and decoders for nearly every language)
var data = { "foo" : "bar", "my_array":[] };

Categories

Resources