I assume the server-side javascript file is ‘.js’ but how do I create a js file from the app builder? no matter where I click in the ‘Files’ section and choose ‘new file’, I always get a .prg file. I ended up creating the js file manually in the file system and then had to close + open the app to see the file under ‘JavaScript Files’ (clicking ‘refresh’ didn’t work).
When entering the filename postfix .js

Once I had the js file & named it properly I could call my function just fine using evaluateJavaScript but what makes this js server-side as it is just another js file in the same folder as my click-handler js file?
Does evaluateJavaScript need the cloud server to work?
This is for web/mobile apps so look at web app view and test in there using the JavaScript console if need be to test call your server-side functions, you don’t use this functionality in a desktop app and that us not a client/server web or mobile app, it’s all running in one exe.

Is there any way to debug server-side js files
Test from the JavaScript console. No there is no remote debugger.

to import an external JS library into lianja

var mylib = require("some_filename.js");
var mylib = require_once("some_filename.js");

require() and require_once() return the module.exports object for consistency. require_once() keeps an internal cache and knows if the library has been loaded already so its module.exports object is used rather than loading the library again. The same goes for include_once().
Also remember that filenames can be prefixed with app:/ or lib:/ which is expanded for you to the full filename path.

I understand the concept of calling a server script from the client and I can see that evaluateJavacsript will allow js code on both sides to work just fine.
What I don’t understand is which files are sent to the client and which stay on the server because both are defined in app builder in exactly the same way so there is nothing so say which is a ‘server’ file and which is a ‘client’ file.
In development mode all JavaScript is referenced in the app or library directories as the “server” is embedded in the app builder.

When you switch to web app view and then “preview” your server side JavaScript is called using a RPC to the cloud server.

You can use Lianja.evaluateJavaScript() or setup the exports.conf file to handle the mapping from client to server function calls.
When using data binding you don’t need to perform any CRUD operations programmatically as it is done for you.
The only time I would perform evaluate() or evaluateJavaScript() RPCs is for validation or custom actions that require specialized CRUD code to be run on the server.

When binding URLs to webviews you can use {…} macros which are substituted as a Webview is refreshed.
The data binding hides a lot of the complexity of client/server operations.

In a js delegate this code gives the error “TypeError: undefined is not a constructor (evaluating ‘poSection.add()’) ”
Digging around in the web debug I can see that poSection appears to be a valid section object and I can see a few other properties but most fail eg ‘.count’

var poSection = Lianja.get("New_Purchase_Order.section1");

A best practice is to use Lianja.showDocument() which abstracts above all of this coding.

this line of code:
lianja.execute(‘lianja.get(“sup_Search.sectionPara meter.Valore”).text = “‘ + “Test” + ‘”‘);
type on command line, work fine
in a javascript script inside a rsp page no…
Lianja.execute() runs a command on the server.

Lianja.get() is a client side API call.

You are executing Lianja.execute() on the client inside a script tag. The command it executes runs on the server. How can it access the client?
Work! the only problem?
Javascript is case sensitive… 🙂

Looking at the apps settings in v2.1Beta12, I noticed some options I don’t recall seeing.
HTML editor – has an option for Desktop, web or Mobile.
There is also another setting option called include in HTML Head.

So that got me thinking…..

Is there a combination that I could use to embed Jquery in a custom javascript section?
A custom JavaScript section is created dynamically and has no meaningful HTML content.
To use jquery you would just need a WebView section.

Lianja v3.0 now includes a GUI JavaScript debugger.

This will be triggered when an error occurs in any of your JavaScript delegates, when you choose “Debug…” from the “Program” menu (or ModeBar button) and choose a JavaScript file, or when a debug() function call is encountered in any JavaScript code. Note that debug() is a noop in the Web/Mobile clients.

In a jssp page, I have created a simple navigation section.
All I am looking to do is step through a table.
I am missing something though.

I can MoveFirst(), MoveLast() without an issue.

MoveNext(), MovePrior(), MoveRelative() all seem to start from the first record each time they are clicked.

How do I keep the record pointer from resetting itself.

Below is my very simple jssp page. I am purposely mixing the Lianja and javascript code so I can understand how they interact.

<%@ Language=JavaScript %>

var moveLast = function(){


var moveFirst = function(){


var moveNext = function(){


var movePrevious = function(){


var moveRelative= function(){


window.onload = function(){
document.getElementById("btnMoveLast").onclick = moveLast;
document.getElementById("btnMoveFirst").onclick = moveFirst;
document.getElementById("btnMoveNext").onclick = moveNext;
document.getElementById("btnMovePrevious").onclick = movePrevious;
document.getElementById("btnMoveRelative").onclick = moveRelative;





print('<label for ="firstname" >First Name</label>')
print('<input type = "text" id = "firstname" >')
print('<label for ="lastname" >Last Name</label>')
print('<input type = "text" id = "lastname">')
print('<label for ="recno" >Recno </label>')
print('<input type = "text" id = "recno">')
<input type ="button" id = "btnMoveFirst" value ="First">
<input type ="button" id = "btnMoveLast" value ="Last">
<input type ="button" id = "btnMoveNext" value ="Next">
<input type ="button" id = "btnMovePrevious" value ="Previous">
<input type ="button" id = "btnMoveRelative" value ="Relative 5">



How do I create a JavaScript function that can step through a table and populate my html <input> tags.
Everything between <% and %> is processed and executed on the server as the html is being generated and sent to the WebView.

so the html you are generating does not look correct to me.
You build it as an App with one WebView that has the LianjaWebFramework in it and you can use Lianja.getCursor() etc to navigate the data.

I Have created a simple JavaScript function that I am using to populate a ShowDialog window.
I am having an issue trying to get a click event working properly.

I have tried both an anonymous function on a named function, but no luck.

Below is the code with the named function.

What seems to occur is that click events is triggered when dialog function is called, but then does not respond when I click the button.

function myDialog(){

var buttontest = function(){
myTextBox.text = "test";

var cont = createObject("myContainer", "container");
cont.backcolor = "silver";
cont.autosize = 1;
cont.layout = "horizontal";
cont.addObject("myTextBox", "textbox"); 

cont.addObject("myButton", "commandbutton");
myButton.text = "Update";
myButton.click = buttontest();

return cont;

Is there a different way I should be calling the click event on the button?
you should be assigning buttontest not buttontest()

buttontest is the address of the function whereas buttontest() executes it and assigns the return value which in your case is undefined.
names of the objects need to be lowercase not mixed case.

There are times when you may need to use a percentage sign in your app.

In my case, I am filtering a grid using the like statement against SQL Server.
since the % sign is a mod function in javascript, you need to escape it out using %25.
So in my case, I concatenate the value to my textbox value.

function page1_section1_field2_click()
var m_filter1 = txtfilter.value;
var m_filter = '%25'+m_filter1+'%25';

Lianja.get("page1.Al_SQLServers").filter ="computername like '"+m_filter+"'";


I noticed you switched from VFP to JSCRIPT, any particular reason why?
I chose JavaScript since I want the app to be able to run in a web browser.
Since I used txt1.value and txt2.value as parameters to the call, I wanted to make sure the browser would understand those values.

VFP and JS, side-by-side

If you want to test some web code snippets on the fly look at https://jsfiddle.net/
JS (w/ jQuery)

Although you have not LOM in this case, it can help to learn JavaScript, CSS and HTML syntax.


Categories JS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s