Create a class to update the record and refresh the form
Today we have a requriemnt that on form there is button. when user click on that button yes & no popoup will come and after that its will update the record and reresh form.
We have done this using a call and attached that class in the action menu item set the enum property.
class NGOfferLetterHeaderStatusChange
{
NGOfferLetterHeader offerLetterHeader;
NGOfferLetterApplicationStatus offerLetterApplicationStatus;
public boolean dialog()
{
boolean ret = false;
if (Box::okCancel(strfmt("@SYS53061", offerLetterApplicationStatus), DialogButton::Ok, "@SYS31424") == DialogButton::Ok)
{
ret = true;
}
return ret;
}
protected void new(NGOfferLetterHeader _offerLetterHeader, NGOfferLetterApplicationStatus _offerLetterApplicationStatus)
{
offerLetterHeader = _offerLetterHeader;
offerLetterApplicationStatus = _offerLetterApplicationStatus;
}
public void run()
{
NGOfferLetterHeader offerLetterHeaderUpdate;
ttsbegin;
setprefix("@SYS31319");
offerLetterHeaderUpdate = NGOfferLetterHeader::findByRecId(offerLetterHeader.RecId, true);
offerLetterHeaderUpdate.NGOfferLetterApplicationStatus = offerLetterApplicationStatus;
if (offerLetterHeaderUpdate.validateWrite())
{
offerLetterHeaderUpdate.update();
}
ttscommit;
}
client static void main(Args args)
{
NGOfferLetterHeaderStatusChange offerLetterHeaderStatusChange;
NGOfferLetterHeader offerLetterHeader;
FormDataSource offerLetterHeader_ds;
NGOfferLetterApplicationStatus offerLetterApplicationStatus;
if (!args)
{
throw error("@SYS30498");
}
if (args.record().TableId != tablenum(NGOfferLetterHeader))
{
throw error("@SYS30498");
}
offerLetterHeader = args.record();
offerLetterHeader_ds = FormDataUtil::getFormDataSource(offerLetterHeader);
offerLetterApplicationStatus = args.parmEnum();
offerLetterHeaderStatusChange = new NGOfferLetterHeaderStatusChange(offerLetterHeader, offerLetterApplicationStatus);
if (offerLetterHeaderStatusChange.dialog())
{
offerLetterHeaderStatusChange.run();
if (offerLetterHeader_ds)
{
offerLetterHeader_ds.reread();
offerLetterHeader_ds.refresh();
offerLetterHeader_ds.active();
}
}
}
}
Comments
Post a Comment