In Axapta, edit method is allow us to edit the data that not belong to the selected form datasource.
Example:
1. I wan to add DirPersonPartyDetail.Gender to Profile management form.
2. However In Profile management form, the datasource of the overview tab is VendTable
3. Hence I need to add a edit method in VendTable method to allow user view and edit the gender.
the code as below :-
//standard - edit FreeTxt txtDefault(boolean Set, FreeTxt Txt)
edit Gender getGender(boolean set, Gender _gender)
{
DirPersonPartyDetail _dirPersonPartyDetail;
Gender _localGender;
;
// if user select the record and edit the gender data
if (set)
{
ttsbegin;
//select the record , if exit then update else incert
Select firstonly forupdate _dirPersonPartyDetail where _dirPersonPartyDetail.PartyId == this.PartyId;
if (_dirPersonPartyDetail.RecId)
{
_dirPersonPartyDetail.Gender = _gender;
_dirPersonPartyDetail.update();
}
else
{
_dirPersonPartyDetail.Gender = _gender;
_dirPersonPartyDetail.PartyId = this.PartyId;
_dirPersonPartyDetail.insert();
}
ttscommit;
_localGender = _gender;
}
//work as display method to display the gender record for all ven account.
else
{
Select firstonly _dirPersonPartyDetail where _dirPersonPartyDetail.PartyId == this.PartyId;
_localGender = _dirPersonPartyDetail.Gender;
}
//return the latest gender value to screen
return _localGender;
}

No comments:
Post a Comment