Hi All,
please find below requirement.
Requirement: I need to create a button in action pane of form. and form contains records. its a normal custom form. showRowLabels property of grid is set to No. once i click on button selected record should be copy on the same form.
Problem facing: I am able to copy the record on the same form. but that record insert on bottom position of grid. i want to insert record immediate after of selected record which i copied or above of selected record. because if there are 100 of records and user select 2nd record and click on copy button. record will insert at bottom of grid and user needs to be scrolldown.
please find attached screenshot of my code of button click. any suggestion woul be appreciate.
void clicked()
{
SYN_TransactionAllocation _CopytransactionAllocation,copytotransact,refreshtransact;
common recordtofind;
int position;
// super();
_CopytransactionAllocation = SYN_TransactionAllocation::findByRecId(SYN_TransactionAllocation.RecId);
copytotransact.data(SYN_TransactionAllocation);
copytotransact.insert();
recordtofind = SYN_TransactionAllocation::findByRecId(copytotransact.RecId);
SYN_TransactionAllocation_ds.research(true);
SYN_TransactionAllocation_ds.refresh();
SYN_TransactionAllocation_ds.findRecord(recordtofind);
}
The research(true) command refers to the copied record, not the new record. Don’t you need copytotransact.update() after the insert?
This is a handy reference on use of refresh, research:http://kashperuk.blogspot.cz/2010/03/tutorial-reread-refresh-research.html
Hi Mark,
Thanks for your suggession. i have done above requirement. I have written code at datasource create method to acheive the scenario. and now it is working fine.
I am sharing the code as well. thanks again.
public void create(boolean _append = false)
{
SYN_TransactionAllocation _transactalloc,copytotransact,refreshtransact,checkjournalnumwise;
common recordtofind;
int position;
real totalPercentage,variance;
//int64 rec, prevrec;
// if(check!= true) // this if condition will work for new button
// {
_transactalloc = SYN_TransactionAllocation::findByRecId(SYN_TransactionAllocation.RecId);
super(_append);
refreshtransact = SYN_TransactionAllocation::findByRecId(SYN_TransactionAllocation.RecId);
SYN_TransactionAllocation.SYN_TransDate = _transactalloc.SYN_TransDate;
SYN_TransactionAllocation.CheckCopy = "copy";
SYN_TransactionAllocation.JournalNum = _transactalloc.JournalNum;
SYN_TransactionAllocation.LedgerAccountName = _transactalloc.LedgerAccountName;
SYN_TransactionAllocation.Narration = _transactalloc.Narration;
SYN_TransactionAllocation.AmountCurDebit = _transactalloc.AmountCurDebit;
SYN_TransactionAllocation.AmountCurCredit = _transactalloc.AmountCurCredit;
SYN_TransactionAllocation.OffsetAccountName = _transactalloc.OffsetAccountName;
SYN_TransactionAllocation.GeneralJournalAccountEntryRecId = _transactalloc.GeneralJournalAccountEntryRecId;
SYN_TransactionAllocation.LedgerDimension = _transactalloc.LedgerDimension;
SYN_TransactionAllocation.DefaultDimension = _transactalloc.DefaultDimension;
SYN_TransactionAllocation.SYN_District = _transactalloc.SYN_District;
SYN_TransactionAllocation.SYN_Regions = _transactalloc.SYN_Regions;
SYN_TransactionAllocation.SYN_States = _transactalloc.SYN_States;
SYN_TransactionAllocation.MainAccountId = _transactalloc.MainAccountId;
// Start: data entry fields
SYN_TransactionAllocation.ProjId = _transactalloc.ProjId;
SYN_TransactionAllocation.ProjName = _transactalloc.ProjName;
SYN_TransactionAllocation.CategoryId = _transactalloc.CategoryId;
SYN_TransactionAllocation.CategoryName = _transactalloc.CategoryName;
SYN_TransactionAllocation.Percentage = _transactalloc.Percentage;
SYN_TransactionAllocation.AllocatedAmount = _transactalloc.AllocatedAmount;
SYN_TransactionAllocation.ActualAmount = _transactalloc.ActualAmount;
SYN_TransactionAllocation.UserDate = _transactalloc.UserDate;
// End: data entry fields
SYN_TransactionAllocation.SYN_SourcesofFund = _transactalloc.SYN_SourcesofFund;
SYN_TransactionAllocation.Voucher = _transactalloc.Voucher;
SYN_TransactionAllocation.userId = _transactalloc.userId;
SYN_TransactionAllocation.SYN_BudgetCalcDate = _transactalloc.SYN_BudgetCalcDate;
SYN_TransactionAllocation.SYN_LedgerDimension = _transactalloc.SYN_LedgerDimension;
SYN_TransactionAllocation.BudgetAmount = _transactalloc.BudgetAmount;
SYN_TransactionAllocation.Version = _transactalloc.Version;
SYN_TransactionAllocation.HistoryVersion = _transactalloc.HistoryVersion;
select sum(Percentage) from checkjournalnumwise group by JournalNum where checkjournalnumwise.JournalNum == _transactalloc.JournalNum;
totalPercentage = checkjournalnumwise.Percentage + SYN_TransactionAllocation.Percentage;
if(totalPercentage > 100)
{
error("Allocated amount exceeds the Available Budget");
SYN_TransactionAllocation.Percentage = 0;
SYN_TransactionAllocation.AllocatedAmount = 0;
}
variance = SYN_TransactionAllocation.BudgetAmount - SYN_TransactionAllocation.ActualAmount;
if(SYN_TransactionAllocation.AllocatedAmount > variance)
{
warning("Allocated Amount exceeds the Available Budget");
// SYN_TransactionAllocation.AllocatedAmount = 0;
}
SYN_TransactionAllocation_ds.Write();
ttsBegin;
select forUpdate copytotransact where copytotransact.RecId == SYN_TransactionAllocation.RecId;
copytotransact.CheckCopy = "";
copytotransact.doUpdate();
ttsCommit;
}