below code to update customer/Vendor contact details like email, telephone, fax, etc.,
CustTable custTable;
void setUpContacts(Addressing _desc, RefRecId _party,LogisticsElectronicAddressMethodType _type,LogisticsElectronicAddressLocator _value )
{
DirPartyLocation dirPartyLocation,dirPartyLocationNew;
LogisticsLocation logisticsLocation;
LogisticsElectronicAddress logEleAddress;
select forupdate forUpdate dirPartyLocation where dirPartyLocation.Party == _party
join logisticsLocation where logisticsLocation.Description == _desc
&& logisticsLocation.recid==dirPartyLocation.Location
join forUpdate logEleAddress where logEleAddress.Location == logisticsLocation.recid
&& logEleAddress.Type == _type;
if(logEleAddress.RecId != 0 && logEleAddress.Locator != _value)
{
ttsBegin;
logEleAddress.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
logEleAddress.Locator = _value;
logEleAddress.update();
ttsCommit;
}
else if(logEleAddress.RecId == 0)
{
logisticsLocation = LogisticsLocation::create(_desc);
dirPartyLocationNew.Party = _party;
dirPartyLocationNew.Location = logisticsLocation.RecId;
dirPartyLocationNew.ValidFrom = DateTimeUtil::utcNow();
dirPartyLocationNew.ValidTo = DateTimeUtil::maxValue();
dirPartyLocationNew.insert();
logEleAddress.Location = logisticsLocation.RecId;
logEleAddress.Type = _type;
logEleAddress.Locator = _value;
logEleAddress.insert();
}
}
custTable = CustTable::find("C004800");
setUpContacts("Email",custTable.Party,LogisticsElectronicAddressMethodType::Email,"prasan@domain.com");
//Contact Name/description, Party, contact type, Email address
CustTable custTable;
void setUpContacts(Addressing _desc, RefRecId _party,LogisticsElectronicAddressMethodType _type,LogisticsElectronicAddressLocator _value )
{
DirPartyLocation dirPartyLocation,dirPartyLocationNew;
LogisticsLocation logisticsLocation;
LogisticsElectronicAddress logEleAddress;
select forupdate forUpdate dirPartyLocation where dirPartyLocation.Party == _party
join logisticsLocation where logisticsLocation.Description == _desc
&& logisticsLocation.recid==dirPartyLocation.Location
join forUpdate logEleAddress where logEleAddress.Location == logisticsLocation.recid
&& logEleAddress.Type == _type;
if(logEleAddress.RecId != 0 && logEleAddress.Locator != _value)
{
ttsBegin;
logEleAddress.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
logEleAddress.Locator = _value;
logEleAddress.update();
ttsCommit;
}
else if(logEleAddress.RecId == 0)
{
logisticsLocation = LogisticsLocation::create(_desc);
dirPartyLocationNew.Party = _party;
dirPartyLocationNew.Location = logisticsLocation.RecId;
dirPartyLocationNew.ValidFrom = DateTimeUtil::utcNow();
dirPartyLocationNew.ValidTo = DateTimeUtil::maxValue();
dirPartyLocationNew.insert();
logEleAddress.Location = logisticsLocation.RecId;
logEleAddress.Type = _type;
logEleAddress.Locator = _value;
logEleAddress.insert();
}
}
custTable = CustTable::find("C004800");
setUpContacts("Email",custTable.Party,LogisticsElectronicAddressMethodType::Email,"prasan@domain.com");
//Contact Name/description, Party, contact type, Email address
No comments:
Post a Comment