Try OpenEdge Now
skip to main content
Application Developer's Guide
Developing an application : Using JavaScript in a workstep : Integrating JavaScript : Updating dataslot values
 
Updating dataslot values
Unliketask the methods you use to read a dataslot, the only method to update a dataslot is typeless. To update a dataslot, use the following code:
jst.putDataSlot(dsName, JavaScriptVariableName);
where dsName is the actual dataslot name and JavaScriptVariableName is the name of the JavaScript variable that holds the new value you want to assign to the dataslot.
Important: The datatype of the JavaScript variable should match the datatype of the dataslot.
For example, you could use the following code to read and update a dataslot (without changing its value):
var name = jst.getDataSlotValue("empName");
var salary = jst.getDataSlotValue("empSalary");
jst.putDataSlot("empName", name);
jst.putDataSlot("empSalary", salary);
If you want to update the date dataslot, then the following method provides an example:
jst.putDataSlot(String dsName, Object dsValue);
var jdt = (new java.util.Date()).getTime();
var currentTime = new
Packages.com.savvion.sbm.bizlogic.server.svo.DateTime.getInstance(jdt);
jst.putDataSlot("dsDate", currentTime);
If you want to set decimal values dataslots, then the following method provides an example:
/*
For setting Decimal values setScale(int scale, int roundingMode) should
be used.
*/
var jdec = new java.math.BigDecimal(2222.555);
var bigdec = new
Packages.com.savvion.sbm.bizlogic.server.svo.Decimal.getInstance(jdec.
setScale(5,java.math.BigDecimal.ROUND_UP));
jst.putDataSlot("dsDecimal", bigdec);