Hi guys,
i have a scenario before post i need it validation Fromdate, todate, leavetype should be filled but in my form post button Runbase batch class mentioned
how to validate below my code : table name MPWorkerTransHeader rec; buffer.
// This is a framework class. Customizing this class may cause problems with future upgrades to the software.
class MPPostMulti extends RunBaseBatch
{
// Packed variables
FormDataSource callerDs;
TransDate trDate;
// Dialog fields
//DialogField dlgCustAccount;
//DialogField dlgTransDate;
#define.CurrentVersion(2)
#define.Version1(2)
#localmacro.CurrentList
trDate
#endmacro
///
/// Indicates whether the class is shown in the list of Journal types.
///
///
/// true if the class is shown in the list of Journal types; otherwise, false.
///
///
/// A class that can be used in a batch journal is a class where the same parameters can be used
/// repeatedly. The dialog box can be shown and the parameters can be changed, but parameters of some
/// classes might build on data that is only valid for a short time. Running a class two times with the
/// same parameters is not always possible. If the RunBaseBatch.canGoBatch method is false, this
/// method will not have any effect.
///
public boolean canGoBatchJournal()
{
return true;
}
///
/// Returns a class that contains the methods that are described by the RunBaseDialogable
/// interface.
///
///
/// A class that contains the methods that are described by the RunBaseDialogable interface.
///
///
/// A dialog box can be either built by using the Dialog class or by using a class that is
/// created in the Application Object Tree (AOT).
///
public Object dialog()
{
DialogRunbase dialog = super();
#resAppl
;
/*dialog.addImage(#ImageEmployee);
dialog.addInfoImage();
dlgTransDate = dialog.addFieldValue(extendedTypeStr(TransDate),transDate);
dialog.addTabPage("@SYS76580");
dlgCustAccount = dialog.addFieldValue(extendedTypeStr(CustAccount),custAccount);*/
return dialog;
}
public void dialogPostRun(DialogRunbase dialog)
{
;
super(dialog);
}
public boolean getFromDialog()
{
;
/*transDate = dlgTransDate.value();
custAccount = dlgCustAccount.value();*/
return super();
}
public boolean init()
{
return true;
}
protected void new(FormDataSource ds)
{
super();
callerDs = ds;
}
public container pack()
{
return [#CurrentVersion,#CurrentList];
}
///
/// Contains the code that does the actual job of the class.
///
public void run()
{
#OCCRetryCount
if (! this.validate())
throw error("");
try
{
ttsbegin;
this.Update();
ttscommit;
}
catch (Exception::Deadlock)
{
retry;
}
catch (Exception::UpdateConflict)
{
if (appl.ttsLevel() == 0)
{
if (xSession::currentRetryCount() >= #RetryNum)
{
throw Exception::UpdateConflictNotRecovered;
}
else
{
retry;
}
}
else
{
throw Exception::UpdateConflict;
}
}
}
public boolean runsImpersonated()
{
return true;
}
public boolean unpack(container packedClass)
{
Version version = RunBase::getVersion(packedClass);
;
switch (version)
{
case #CurrentVersion:
[version,#CurrentList] = packedClass;
break;
default:
return false;
}
return true;
}
private void update()
{
MPWorkerTransHeader row;
MPPostEmplTransaction postTrans;
Args args;
if (callerDs.anyMarked())
{
//Obtains the first query result and then assign it to table buffer
row = callerDs.getFirst( 1, false );
//True if purchLineView contains RecId
while (row)
{
args = new args();
args.record(row);
postTrans = MPPostEmplTransaction::construct(args);
postTrans.initParmDefault();
postTrans.parmTransHeader(row);
postTrans.run();
//Shows all RecIds from selected grid rows
//info( strFmt('%1' , row.RecId));
//Gets next record
row = callerDs.getNext();
}
}
else
{
info("@MPL514");
}
callerDs.reread();
callerDs.refresh();
}
public boolean validate(Object _calledFrom = null)
{
if (false)
return checkFailed("");
return true;
}
server static MPPostMulti construct(FormDataSource ds)
{
return new MPPostMulti(ds);
}
// Here goes a description of the class
static ClassDescription description()
{
return "@MPL98";
}
static void main(Args args)
{
MPPostMulti MPPostMulti;
MPPostEmplTransaction postTrans;
MPWorkerTransHeader rec;
FormDataSource trans_ds;
;
if(!args
|| !args.record())
{
error("@MPL513");
return;
}
//Check if the Args.Record() has the same TableID as the Table Buffer(custTable).
if (args.record().TableId == tableNum(MPWorkerTransHeader))
{
//Assign the args records to table buffer and then pass it to salesLine_ds(FormDataSource)
rec = args.record();
trans_ds = rec.dataSource();
if(trans_ds.anyMarked())
{
MPPostMulti = MPPostMulti::construct(trans_ds);
if (MPPostMulti.prompt())
{
MPPostMulti.run();
}
}
else if(rec.RecId)
{
ttsBegin;
args = new args();
args.record(rec);
postTrans = MPPostEmplTransaction::construct(args);
postTrans.initParmDefault();
postTrans.parmTransHeader(rec);
postTrans.run();
ttsCommit;
}
else
{
error("@MPL514");
}
}
}
}
Thanks