Verj.io Javascript – Quick Reference Card

 

Getting a field value

 

var val = fields.Requestor.value;

 

 

Setting a field value

 

fields.Department.value = "Finance";

fields.TodaysDate.value = new Date();

fields.time_now.value = new Date();

 

 

Adding a list to a field

 

var list = ["Line 1", "Line 2", "Line 3"];

fields.ListField.createCustomList(list);

 

 

 

Inserting a new row into a Table

 

tables.Order_Items.insertRow();

 

 

Setting a Table column value

 

tables.Order_Items.ItemAmount.value = fields.Amount.value;

 

 

Saving Table data to its backing resource

 

tables.Order_Items.updateTable();

 

 

Loading a Table via its backing resource

 

var rows = tables.Requests.fetchTable();

while ( rows.next() ) { .. }

 

 

Looping through table rows

 

var rows = tables.Requests.rows;

while ( rows.next() )

{

fields.Total.value += tables.Requests.Amount.value;

}

 

Sorting Table data

 

tables.Requests.sort(tables.Requests.Date,

                       Table.SORT_DIRECTION_DESCENDING);

 


 

Working with Controls

 

controls.Button1.backgroundColor = "Yellow";

controls.Text1.text.text = "Hello";

controls.Panel5.hide();

 

 

Calling a Form

 

var parms = {};

parms.OrderId = fields.Order.stringValue;

parms.CustomerId = fields.Customer.stringValue;

parms.CredirLimit = 9999;

form.callForm("OrderDisplay", parms);

 

 

Display a specific Page

 

form.gotoPage(pages.OrderPage);

 

 

Working with Resources

 

resources.Requests.update();

resources.Email1.sendmail();

resources.Hr_Get_Employee_Details_Ws.call();

 

 

Incrementing a Sequence

 

var next = system.sequenceManager.sequence("SEQ1");

 

 

Issuing Messages

 

controls.FieldControl1.addWarningMessage("This is a warning message..");

event.owner.addErrorMessage("Your input is invalid..");

 

// multiple error messages

event.owner.addErrorMessage("Message 1..", false);

event.owner.addErrorMessage("Message 2.." , false);

event.owner.addErrorMessage("Message 3.." , false);

event.stopExecution();

 


 

File Services

 

FileServices.createNewFile("C:/files/myfile.txt");

FileServices.copyFile("C:/files/myfile.txt",

                              "C:/more_files/myfile.txt");

FileServices.deleteFile("C:/files/myfile.txt");

 

 

Security Services – logging on and off

 

system.securityManager.logon(

      [ ["Script", fields.USER.value],

        ["Script", fields.PASSWORD.value]  ] );

 

system.securityManager.logoff();

 

 

Working with modifiers

 

var page = pages.Page1;
for each (var ctrl in page.getControlsByModifier("Audit"))
{
   if (!system.securityManager.hasRole("FINANCE_CONTROLLER"))
   {
      ctrl.hide();
   }
 }
 

 

Handing Exceptions

 

try
{
system.securityManager.logon([ ["Script", fields.USER.value], 
    ["Script", fields.PASSWORD.value] ]);
}
catch (e)
{
  event.owner.addErrorMessage(e);  
  log (e);
}

 

 

Accessing Java classes

 

var date = new java.util.Date();

var d1 = date.getTime();

var cal = java.util.Calendar.getInstance();

var d2 = cal.getFirstDayOfWeek();