I designed a Modscript to change the Balance field value of the Auxiliary table. After deployed the application, the value of Balance in Auxiliary table wasn't updated, but a new record was added to the Auxiliary table. Following shows where the Modscript is called, tables, and Modscript.
Primary table: Leave Requests
Auxiliary Table: Employee Vaction Balance
def changeBalance(userId) {
var fldValue = int();
var timeTaken = int();
var user = Ext.CreateAppRecord (Ext.TableId("USR_LEAVE_REQUESTS"));
user.ReadWithWhere("TS_EMPLOYEE=${userId}");
user.GetFieldValue("TS_ACTUAL_TIME_TAKEN", timeTaken);
var oldBalance =int();
var newBalance =int();
var balanceSelect = Ext.CreateAppRecord (Ext.TableId("USR_EMPLOYEE_VACTION_BALANCE"));
balanceSelect.ReadWithWhere("TS_EMPLOYEE=${userId}");
balanceSelect.GetFieldValue("TS_BALANCE", oldBalance);
newBalance = oldBalance - timeTaken;
balanceSelect.SetFieldValue("TS_BALANCE", newBalance);
var submit = balanceSelect.QuickSubmitToAux();
Ext.LogErrorMsg("Balance is changed!!!");
}
global u = int();
u = Shell.Item().GetFieldValue("Employee");
changeBalance(u);