Skip to content

Instantly share code, notes, and snippets.

@bayramcetin
Last active March 21, 2022 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bayramcetin/a0200a76c09a979fa7ee6ebb88eef5d3 to your computer and use it in GitHub Desktop.
Save bayramcetin/a0200a76c09a979fa7ee6ebb88eef5d3 to your computer and use it in GitHub Desktop.
Email, Phone Create or Update
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