Tuesday 9 June 2015

PROSPECT INTEGRATION CREATION AX 2012 X++ CUSTOM WEB SERVICE

PROSPECT INTEGRATION CREATION AX 2012 
X++ CUSTOM WEB SERVICE

Prospect Integration create
[AifCollectionTypeAttribute('return', Types::String), SysEntryPointAttribute(true)]
public str CreateProspect(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                   partyRecord;
    DirPersonName                   person;
    DirPerson                       pers;
    smmBusRelTable                  prospect;
    DirPartyContactInfoView         contactinfo,dirPartyContactInfoEmail,dirPartyContactInfoFax;
    str                             log;
    container                       roles_delivery,roles_invoice;
    DirParty                        dirParty;
    DirPartyPostalAddressView       dirPartyPostalAddressView;
    str                             log_1,log_2,log_3,log_4,log_5,log_6;

   if(_groupId != 'del')
            changeCompany('DEL')
    {
      if(!smmBusRelTable::exist(_prospectId) && _prospectId != ''&& _name !="" && CustGroup::exist(_groupId) && (DlvTerm::exist(_term) || _term == "")
            && (DlvMode::exist(_mode) || _mode == ""))
        //Creating record  in
        {

            //Creating record  in Prospect master
          //  errorlog = 'done';
            ttsBegin;
            prospect.clear();
            prospect.BusRelAccount = _prospectId;
            prospect.CustGroup = _groupId;
            prospect.BusRelTypeId = 'Prospect';
            if(_Currency == "")
            {
                prospect.Currency = "INR";
            }
            else
            {
               prospect.Currency  = _Currency;
            }

            prospect.DlvMode  = _mode;
            prospect.DlvTerm  = _term;
            prospect.TaxGroup = _salesTax;
            partyRecord            = DirPartyTable::createNew(DirPartyType::Organization, _name);
            partyRecord.update();
            prospect.Party = partyRecord.RecId;
            prospect.insert();
            dirParty = DirParty::constructFromCommon(prospect);
        //  creating Address
            dirPartyPostalAddressView.CountryRegionId        = _country1;
            dirPartyPostalAddressView.ZipCode                = _zipCode1;
            dirPartyPostalAddressView.Street                 = _street1;
            dirPartyPostalAddressView.BuildingCompliment     = _building;
            dirPartyPostalAddressView.PostBox                = _street3;
            dirPartyPostalAddressView.City                   = _city;
            dirPartyPostalAddressView.State                  = _state;
            dirPartyPostalAddressView.DistrictName           = _district;
            dirPartyPostalAddressView.LocationName           = _name;
            dirPartyPostalAddressView.IsPrimary              = NoYes::Yes;
            roles_delivery = [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Delivery).RecId];
            dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView,roles_delivery);
            //second address
            dirPartyPostalAddressView.CountryRegionId        = _country2;
            dirPartyPostalAddressView.ZipCode                = _zipCode2;
            dirPartyPostalAddressView.Street                 = _street2;
            dirPartyPostalAddressView.BuildingCompliment     = _building2;
            dirPartyPostalAddressView.PostBox                = _street32;
            dirPartyPostalAddressView.City                   = _city2;
            dirPartyPostalAddressView.State                  = _state2;
            dirPartyPostalAddressView.DistrictName           = _district2;
            dirPartyPostalAddressView.LocationName           = _name;
            dirPartyPostalAddressView.IsPrimary              = NoYes::No;
            roles_invoice = [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Invoice).RecId];
            dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView,roles_invoice);
                // Update address

            if(_phone || _extension)
            {
                if(_Phone)
                {
                    contactinfo.LocationName                 =  _name;
                    contactinfo.Locator                      =  _Phone;
                    contactinfo.Type                         =  LogisticsElectronicAddressMethodType::Phone;
                    contactinfo.IsPrimary                    =  NoYes::Yes;
                }
                if(_Extension)
                {
                    contactinfo.LocatorExtension             =  _Extension;
                }
               dirParty.createOrUpdateContactInfo(contactinfo);
            }
            //Fax
            if(_Fax)
            {
                dirPartyContactInfofax.Type                         = LogisticsElectronicAddressMethodType::Fax;
                dirPartyContactInfofax.Locator                         = _Fax;
                dirPartyContactInfofax.LocationName              = _name;
                dirParty.createOrUpdateContactInfo(dirPartyContactInfofax);
            }
            //Email
            if(_email)
            {
                dirPartyContactInfoemail.Type                    = LogisticsElectronicAddressMethodType::Email;
                dirPartyContactInfoemail.Locator            = _email;
                dirPartyContactInfoemail.LocationName              =_name;
                dirParty.createOrUpdateContactInfo(dirPartyContactInfoemail);
            }
            // Updating contacts

            ttsCommit;
            log = 'Prospect created successfully';
         }
        else
        {
            if(smmBusRelTable::exist(_prospectId))
            {
               log_1 = 'Prospect  already exist' ;
            }
            if(_prospectId == '')
            {
                log_2 = 'Prospect Id cannot be blank';
            }
            if(_name == '')
            {
                log_3 = 'Name cannot be blank';
            }
            if(!CustGroup::exist(_groupId))
            {
                log_4 = 'Customer Group is not valid';
            }
            if((!DlvTerm::exist(_term) && _term != ""))
            {
                log_5 = 'Term of delivery is not valid';
            }
            if((!DlvMode::exist(_mode) && _mode != ""))
            {
                log_6 = 'Mode of delivery is invalid';
            }

            log = strFmt("%1\n%2\n%3\n%4\n%5\n%6",log_1,log_2,log_3,log_4,log_5,log_6);
        }

      }
      else
      {
           changeCompany('HYUT')

      if(!smmBusRelTable::exist(_prospectId) && _prospectId != ''&& _name !="" && CustGroup::exist(_groupId) && (DlvTerm::exist(_term) || _term == "")
            && (DlvMode::exist(_mode) || _mode == ""))
        //Creating record  in
        {

            //Creating record  in Prospect master
          //  errorlog = 'done';
            ttsBegin;
            prospect.clear();
            prospect.BusRelAccount = _prospectId;
            prospect.CustGroup = _groupId;
            prospect.BusRelTypeId = 'Prospect';
            if(_Currency == "")
            {
                prospect.Currency = "INR";
            }
            else
            {
               prospect.Currency  = _Currency;
            }

            prospect.DlvMode  = _mode;
            prospect.DlvTerm  = _term;
            prospect.TaxGroup = _salesTax;
            partyRecord            = DirPartyTable::createNew(DirPartyType::Organization, _name);
            partyRecord.update();
            prospect.Party = partyRecord.RecId;
            prospect.insert();
            dirParty = DirParty::constructFromCommon(prospect);
        //  creating Address
            dirPartyPostalAddressView.CountryRegionId        = _country1;
            dirPartyPostalAddressView.ZipCode                = _zipCode1;
            dirPartyPostalAddressView.Street                 = _street1;
            dirPartyPostalAddressView.BuildingCompliment     = _building;
            dirPartyPostalAddressView.PostBox                = _street3;
            dirPartyPostalAddressView.City                   = _city;
            dirPartyPostalAddressView.State                  = _state;
            dirPartyPostalAddressView.DistrictName           = _district;
            dirPartyPostalAddressView.LocationName           = _name;
            dirPartyPostalAddressView.IsPrimary              = NoYes::Yes;
            roles_delivery = [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Delivery).RecId];
            dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView,roles_delivery);
            //second address
            dirPartyPostalAddressView.CountryRegionId        = _country2;
            dirPartyPostalAddressView.ZipCode                = _zipCode2;
            dirPartyPostalAddressView.Street                 = _street2;
            dirPartyPostalAddressView.BuildingCompliment     = _building2;
            dirPartyPostalAddressView.PostBox                = _street32;
            dirPartyPostalAddressView.City                   = _city2;
            dirPartyPostalAddressView.State                  = _state2;
            dirPartyPostalAddressView.DistrictName           = _district2;
            dirPartyPostalAddressView.LocationName           = _name;
            dirPartyPostalAddressView.IsPrimary              = NoYes::No;
            roles_invoice = [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Invoice).RecId];
            dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView,roles_invoice);
                // Update address

            if(_phone || _extension)
            {
                if(_Phone)
                {
                    contactinfo.LocationName                 =  'Phone No';
                    contactinfo.Locator                      =  _Phone;
                    contactinfo.Type                         =  LogisticsElectronicAddressMethodType::Phone;
                    contactinfo.IsPrimary                    =  NoYes::Yes;
                }
                if(_Extension)
                {
                    contactinfo.LocatorExtension             =  _Extension;
                }
               dirParty.createOrUpdateContactInfo(contactinfo);
            }
            //Fax
            if(_Fax)
            {
                dirPartyContactInfofax.Type                         = LogisticsElectronicAddressMethodType::Fax;
                dirPartyContactInfofax.Locator                         = _Fax;
                dirPartyContactInfofax.LocationName              = 'Fax';
                contactinfo.IsPrimary                    =  NoYes::Yes;
                dirParty.createOrUpdateContactInfo(dirPartyContactInfofax);
            }
            //Email
            if(_email)
            {
                dirPartyContactInfoemail.Type            = LogisticsElectronicAddressMethodType::Email;
                dirPartyContactInfoemail.Locator         = _email;
                dirPartyContactInfoemail.LocationName    = 'E Mail';
                contactinfo.IsPrimary                    =  NoYes::Yes;
                dirParty.createOrUpdateContactInfo(dirPartyContactInfoemail);
            }
            // Updating contacts

            ttsCommit;
            log = 'Prospect created successfully';
         }
        else
        {
            if(smmBusRelTable::exist(_prospectId))
            {
               log_1 = 'Prospect  already exist' ;
            }
            if(_prospectId == '')
            {
                log_2 = 'Prospect Id cannot be blank';
            }
            if(_name == '')
            {
                log_3 = 'Name cannot be blank';
            }
            if(!CustGroup::exist(_groupId))
            {
                log_4 = 'Customer Group is not valid';
            }
            if(!(DlvTerm::exist(_term) && _term == ""))
            {
                log_5 = 'Term of delivery is not valid';
            }
            if(!(DlvMode::exist(_mode) && _mode == ""))
            {
                log_6 = 'Mode of delivery is invalid';
            }

            log = strFmt("%1\n%2\n%3\n%4\n%5\n%6",log_1,log_2,log_3,log_4,log_5,log_6);
        }



      }

     return log ;
    }

No comments:

Post a Comment

AZURE INTERVIEW QUESTIONS AND ANSWERS

AZURE INTERVIEW QUESTIONS AND ANSWERES 2021 2. What is cloud computing? Explanation:  It is the use of servers on the internet to “store...