PROSPECT INTEGRATION UPDATION AX 2012
X++ CUSTOM WEB SERVICE
Prospect Integration Update[AifCollectionTypeAttribute('return', Types::String), SysEntryPointAttribute(true)]
public str UpdateProspect(smmBusRelAccount _prospectId,DirPartyName _name,CurrencyCode _currency,smmDlvTermId _term,smmDlvModeId _mode,
LogisticsAddressCountryRegionId _country1,LogisticsAddressZipCodeId _zipCode1,LogisticsAddressStreet _street1,
LogisticsAddressBuildingCompliment _building,LogisticsAddressPostBox _street3,LogisticsAddressCity _city,LogisticsAddressStateId _state,
LogisticsAddressDistrictName _district,LogisticsElectronicAddressLocator _phone,LogisticsElectronicAddressLocator _extension,LogisticsElectronicAddressLocator _email,LogisticsElectronicAddressLocator _fax,
LogisticsAddressCountryRegionId _country2,LogisticsAddressZipCodeId _zipCode2,LogisticsAddressStreet _street2,
LogisticsAddressBuildingCompliment _building2,LogisticsAddressPostBox _street32,LogisticsAddressCity _city2,LogisticsAddressStateId _state2,
LogisticsAddressDistrictName _district2,
CustGroupId _groupId,TaxGroup _salesTax)
{
DirPartyTable _DirPartyTable;
smmBusRelTable prospect;
DirPartyContactInfoView contactView;
container roles_delivery,roles_invoice;
DirParty dirParty;
DirPartyPostalAddressView postaladdressView,dirPartyPostalAddressView;
str log_1,log_2,log_3,log_4,log_5,log_6;
str log;
if(_groupId != 'del')
changeCompany('DEL')
{
if( smmBusRelTable::exist(_prospectId) && _name !="" && CustGroup::exist(_groupId) && (DlvTerm::exist(_term) || _term == "")
&& (DlvMode::exist(_mode) || _mode == "") )
{
prospect.clear();
ttsBegin;
select forUpdate prospect where prospect.BusRelAccount == _prospectId;
if(prospect)
{
prospect.DlvTerm = _term;
prospect.DlvMode = _mode;
prospect.TaxGroup = _salesTax;
prospect.CustGroup = _groupId;
if(_Currency == "")
{
prospect.Currency = "INR";
}
else
{
prospect.Currency = _Currency;
}
select forUpdate _DirPartyTable where _DirPartyTable.RecId == prospect.Party;
_DirPartyTable.NameAlias = _name;
_DirPartyTable.Name = _name;
_DirPartyTable.update();
prospect.update();
}
postaladdressView.clear();
select postaladdressView where postaladdressView.Party == prospect.Party && postaladdressView.IsPrimary == NoYes::Yes ;
DirParty = DirParty::constructFromPartyRecId(_DirPartyTable.RecId);
postaladdressView.LocationName = _name;
postaladdressView.CountryRegionId = _country1;
postaladdressView.ZipCode = _zipCode1;
postaladdressView.Street = _street1;
postaladdressView.BuildingCompliment = _building;
postaladdressView.PostBox = _street3;
postaladdressView.City = _city;
postaladdressView.State = _state;
postaladdressView.DistrictName = _district;
postaladdressView.IsPrimary = NoYes::Yes;
roles_delivery = [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Delivery).RecId];
DirParty.createOrUpdatePostalAddress(postaladdressView,roles_delivery);
select postaladdressView where postaladdressView.Party == prospect.Party && postaladdressView.IsPrimary == NoYes::No ;
postaladdressView.LocationName = _name;
postaladdressView.CountryRegionId = _country2;
postaladdressView.ZipCode = _zipCode2;
postaladdressView.Street = _street2;
postaladdressView.BuildingCompliment = _building2;
postaladdressView.PostBox = _street32;
postaladdressView.City = _city2;
postaladdressView.State = _state2;
postaladdressView.DistrictName = _district2;
postaladdressView.IsPrimary = NoYes::No;
roles_invoice = [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Invoice).RecId];
dirParty.createOrUpdatePostalAddress(postaladdressView,roles_invoice);
if(_Phone)
{
contactView.clear();
select contactView where contactView.Party == prospect.Party && contactView.Type == LogisticsElectronicAddressMethodType::Phone;
dirParty = dirParty::constructFromPartyRecId(contactView.Party);
contactView.LocationName = _name;
contactView.Locator = _Phone;
contactView.LocatorExtension = _Extension;
contactView.Type = LogisticsElectronicAddressMethodType::Phone;
contactView.Party = _DirPartyTable.RecId;
contactView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(contactView);
}
if(_email)
{
contactView.clear();
select contactView where contactView.Party == prospect.Party && contactView.Type == LogisticsElectronicAddressMethodType::Email;
dirParty = dirParty::constructFromPartyRecId(contactView.Party);
contactView.LocationName = _name;
contactView.Locator = _email;
contactView.Type = LogisticsElectronicAddressMethodType::Email;
contactView.Party = _DirPartyTable.RecId;
contactView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(contactView);
}
if(_fax)
{
contactView.clear();
select contactView where contactView.Party == prospect.Party && contactView.Type == LogisticsElectronicAddressMethodType::Fax;
dirParty = dirParty::constructFromPartyRecId(contactView.Party);
contactView.LocationName = _name;
contactView.Locator = _fax;
contactView.Type = LogisticsElectronicAddressMethodType::Fax;
contactView.Party = _DirPartyTable.RecId;
contactView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(contactView);
}
ttsCommit;
log = 'Prospect Updated Successfully';
}
else
{
if(!smmBusRelTable::exist(_prospectId))
{
log_1 = ('Prospect Id does not exist');
}
if(_name == '')
{
log_2 = ('Name cannot be blank');
}
if(!CustGroup::exist(_groupId))
{
log_3 = ('Customer GroupId does not exist');
}
if(!DlvTerm::exist(_term) || _term == "")
{
log_4= ('Terms of Delivery does not exist');
}
if(!DlvMode::exist(_mode) || _mode == "")
{
log_5= ('Mode of Delivery does not exist');
}
log = strFmt("%1\n%2\n%3\n%4\n%5",log_1,log_2,log_3,log_4,log_5);
}
}
else
{
changeCompany('HYUT')
if( smmBusRelTable::exist(_prospectId) && _name !="" && CustGroup::exist(_groupId) && (DlvTerm::exist(_term) || _term == "")
&& (DlvMode::exist(_mode) || _mode == "") )
{
prospect.clear();
ttsBegin;
select forUpdate prospect where prospect.BusRelAccount == _prospectId;
if(prospect)
{
prospect.DlvTerm = _term;
prospect.DlvMode = _mode;
prospect.TaxGroup = _salesTax;
prospect.CustGroup = _groupId;
if(_Currency == "")
{
prospect.Currency = "INR";
}
else
{
prospect.Currency = _Currency;
}
prospect.update();
}
select forUpdate _DirPartyTable where _DirPartyTable.RecId == prospect.Party;
_DirPartyTable.NameAlias = _name;
_DirPartyTable.Name = _name;
_DirPartyTable.update();
postaladdressView.clear();
select postaladdressView where postaladdressView.Party == prospect.Party && postaladdressView.IsPrimary == NoYes::Yes ;
DirParty = DirParty::constructFromPartyRecId(_DirPartyTable.RecId);
postaladdressView.CountryRegionId = _country1;
postaladdressView.ZipCode = _zipCode1;
postaladdressView.Street = _street1;
postaladdressView.BuildingCompliment = _building;
postaladdressView.PostBox = _street3;
postaladdressView.City = _city;
postaladdressView.State = _state;
postaladdressView.DistrictName = _district;
postaladdressView.IsPrimary = NoYes::Yes;
roles_delivery = [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Delivery).RecId];
DirParty.createOrUpdatePostalAddress(postaladdressView,roles_delivery);
select postaladdressView where postaladdressView.Party == prospect.Party && postaladdressView.IsPrimary == NoYes::No ;
postaladdressView.CountryRegionId = _country2;
postaladdressView.ZipCode = _zipCode2;
postaladdressView.Street = _street2;
postaladdressView.BuildingCompliment = _building2;
postaladdressView.PostBox = _street32;
postaladdressView.City = _city2;
postaladdressView.State = _state2;
postaladdressView.DistrictName = _district2;
postaladdressView.IsPrimary = NoYes::No;
roles_invoice = [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Invoice).RecId];
dirParty.createOrUpdatePostalAddress(postaladdressView,roles_invoice);
if(_Phone)
{
select contactView where contactView.Party == prospect.Party && contactView.Type == LogisticsElectronicAddressMethodType::Phone;
dirParty = dirParty::constructFromPartyRecId(_DirPartyTable.RecId);
contactView.Locator = _Phone;
contactView.locatorextension = _Extension;
contactView.Type = LogisticsElectronicAddressMethodType::Phone;
contactView.Party = dirParty.getPartyRecId();
contactView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(contactView);
}
if(_email)
{
select contactView where contactView.Party == prospect.Party && contactView.Type == LogisticsElectronicAddressMethodType::Email;
contactView.Locator = _email;
contactView.Type = LogisticsElectronicAddressMethodType::Email;
contactView.Party = _DirPartyTable.RecId;
contactView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(contactView);
}
if(_fax)
{
select contactView where contactView.Party == prospect.Party && contactView.Type == LogisticsElectronicAddressMethodType::Fax;
contactView.Locator = _fax;
contactView.Type = LogisticsElectronicAddressMethodType::Fax;
contactView.Party = _DirPartyTable.RecId;
contactView.IsPrimary = NoYes::Yes;
dirParty.createOrUpdateContactInfo(contactView);
}
ttsCommit;
log = 'Prospect Updated Successfully';
}
else
{
if(!smmBusRelTable::exist(_prospectId))
{
log_1 = ('Prospect Id does not exist');
}
if(_name == '')
{
log_2 = ('Name cannot be blank');
}
if(!CustGroup::exist(_groupId))
{
log_3 = ('Customer GroupId does not exist');
}
if(!DlvTerm::exist(_term) || _term == "")
{
log_4= ('Terms of Delivery does not exist');
}
if(!DlvMode::exist(_mode) || _mode == "")
{
log_5= ('Mode of Delivery does not exist');
}
log = strFmt("%1\n%2\n%3\n%4\n%5",log_1,log_2,log_3,log_4,log_5);
}
}
return log ;
}
No comments:
Post a Comment