Last active
March 21, 2022 07:17
-
-
Save bayramcetin/a0200a76c09a979fa7ee6ebb88eef5d3 to your computer and use it in GitHub Desktop.
Email, Phone Create or Update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void emailCreateOrUpdate(Email _email) | |
{ | |
LogisticsElectronicAddress electronicAddress; | |
LogisticsLocation logisticsLocation; | |
DirPartyLocation dirPartyLocation; | |
DirPartyTable dirPartyTable; | |
CompanyInfo companyInfo; | |
companyInfo = CompanyInfo::find(); | |
electronicAddress = DirParty::primaryElectronicAddress(companyInfo.RecId, LogisticsElectronicAddressMethodType::Email); | |
if(electronicAddress) | |
{ | |
ttsbegin; | |
electronicAddress.selectForUpdate(true); | |
electronicAddress.Locator = _email; | |
electronicAddress.IsPrimary = NoYes::Yes; | |
electronicAddress.update(); | |
ttscommit; | |
} | |
else | |
{ | |
ttsbegin; | |
dirPartyTable = DirPartyTable::findRec(companyInfo.RecId); | |
logisticsLocation.clear(); | |
logisticsLocation.Description = "Email"; | |
logisticsLocation.insert(); | |
dirPartyLocation.clear(); | |
dirPartyLocation.Party = dirPartyTable.RecId; | |
dirPartyLocation.Location = logisticsLocation.RecId; | |
dirPartyLocation.IsPrimary = NoYes::Yes; | |
dirPartyLocation.insert(); | |
electronicAddress.clear(); | |
electronicAddress.Location = logisticsLocation.RecId; | |
electronicAddress.Description = "Email"; | |
electronicAddress.Type = LogisticsElectronicAddressMethodType::Email; | |
electronicAddress.Locator = _email; | |
electronicAddress.IsPrimary = NoYes::Yes; | |
electronicAddress.insert(); | |
dirPartyTable.reread(); | |
dirPartyTable.selectForUpdate(true); | |
dirPartyTable.PrimaryContactEmail = electronicAddress.RecId; | |
dirPartyTable.doUpdate(); | |
ttscommit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment