Using Ebase variables when calling a URL from Javascript

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

neilnewman
Ebase User
Posts: 201
Joined: Fri Dec 20, 2013 1:29 pm
Location: Dartford Borough Council
Contact:

Using Ebase variables when calling a URL from Javascript

#1

Postby neilnewman » Mon Oct 02, 2017 7:04 am

I have a button on a form which calls a Javascript script this calls a URL with a variable:

If I hardcode the value for the uprn field it works OK, however if I try to set it to a form field it does not.

I know I am doing something silly but I am not very hot when it comes to writing Javascript, any pointer/help would be great.


importPackage(com.ebasetech.xi.api);
importPackage(com.ebasetech.xi.services);


//var uprn = '100060871265';

var uprn = fields.value1.displayValue;
window.open('http://windmz.dartford.gov.uk/myproperty/SquizMyPropertyDetails.aspx?uprn=' + uprn);
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Mon Oct 02, 2017 9:39 am

You can't use window.open on the server - it's only available from Javascript within the browser. You could either:

Server side: use form.displayUrl() or..
Client (browser) side: Use Html Element Properties to add a click event handled on the client (instead of the server) - then you can use window.open
0 x

neilnewman
Ebase User
Posts: 201
Joined: Fri Dec 20, 2013 1:29 pm
Location: Dartford Borough Council
Contact:

Re: Using Ebase variables when calling a URL from Javascript

#3

Postby neilnewman » Tue Oct 03, 2017 8:46 am

Many thanks for the help Jon, with your guidance the following code does exactly what we want:
importPackage(com.ebasetech.xi.api);
importPackage(com.ebasetech.xi.services);

var encoder = java.net.URLEncoder;
var encoding = "UTF-8";
var parm1 = encoder.encode(fields.VALUE1.displayValue, encoding);

var url = "http://windmz.dartford.gov.uk/mypropert ... tails.aspx" + "?uprn=" + parm1;
form.displayUrl(url);
0 x


Who is online

Users browsing this forum: No registered users and 7 guests