Month: May 2015

Using Google Map in AX 2012 CU7 R2

In class declaration

#Define.GoogleMapUrl(‘http://maps.google.com?q=\%1’)

*******************************************************************************

Form Init method

url = “Harmain Street” +”,”
+ “Jiddah” +”,”
+ “SA-02″ +”,”
+ “6101” +”,”
+ “SAU”;
url = strReplace(url, “\n”, “,”); // replace newline with commas
url = strfmt(#BingMapURL, url);

super();
ActiveX.Navigate(URL);
ActiveX.allowEdit(false);

*******************************************************************************

void clicked()
{
FormRun formRun;
Args args = new Args();

// #Define.MapURL(‘http://www.bing.com/maps/?q=\%1’)
;
url = Address.Street +”,”
+ Address.City +”,”
+ Address.State +”,”
+ Address.ZipCode +”,”
+ Address.CountryRegionId;
url = strReplace(url, “\n”, “,”); // replace newline with commas

url = System.Web.HttpUtility::UrlEncode(url);

args.name(formstr(MapViewer));
args.parm(strfmt(#BingMapURL, url));
formRun = classFactory.formRunClass(args);

formRun.init();
formRun.run();
formRun.wait();
}

Advertisements

Using Bing Map in AX 2012 CU7 R2

In class declaration

#Define.BingMapURL(‘http://www.bing.com/maps/?q=\%1’)

*******************************************************************************

Form Init method

url = “Harmain Street” +”,”
+ “Jiddah” +”,”
+ “SA-02″ +”,”
+ “6101” +”,”
+ “SAU”;
url = strReplace(url, “\n”, “,”); // replace newline with commas
url = strfmt(#BingMapURL, url);

super();
ActiveX.Navigate(URL);
ActiveX.allowEdit(false);

*******************************************************************************

void clicked()
{
FormRun formRun;
Args args = new Args();

// #Define.MapURL(‘http://www.bing.com/maps/?q=\%1’)
;
url = Address.Street +”,”
+ Address.City +”,”
+ Address.State +”,”
+ Address.ZipCode +”,”
+ Address.CountryRegionId;
url = strReplace(url, “\n”, “,”); // replace newline with commas

url = System.Web.HttpUtility::UrlEncode(url);

args.name(formstr(MapViewer));
args.parm(strfmt(#BingMapURL, url));
formRun = classFactory.formRunClass(args);

formRun.init();
formRun.run();
formRun.wait();
}

Create Opportunity & Prospect with contacts through code in AX 2012

void clicked()
{
smmOpportunityTable _oppTable;
StaggingOpportunity _stagOpportunity;
ContactPerson _contactPerson;
LogisticsLocation _logisticLocation;
LogisticsElectronicAddress _logisticEAddress, _logisticEAddressI;
DirPartyLocation _dirPartyLocation;
RecId _dirPartyCompanyId, _dirPartyPersonId, _owner;
;

if(StaggingOpportunity.IsInjected == NoYes::No)
{
try
{
ttsBegin;

_dirPartyCompanyId = DirPartyTable::createNew(DirPartyType::Organization, StaggingOpportunity.Company).RecId;
_dirPartyPersonId = DirPartyTable::createNew(DirPartyType::Person, StaggingOpportunity.Name).RecId;
_owner = Hcmworker::findByPerson(DirPersonUser::find(curUserId()).PersonParty).RecId;

//Creation of the opportunity
//On the creation of the opportunity, system will automatically create the Prospect
_oppTable.clear();
_oppTable.Subject = StaggingOpportunity.Subject;
_oppTable.OpenedByWorker = _owner;
_oppTable.OpenedDate = today();
_oppTable.OwnerWorker = _owner;
_oppTable.Party = _dirPartyCompanyId;
_oppTable.Status = smmOpportunityStatus::Active;
_oppTable.insert();

//Creation of Contact detail
_contactPerson.clear();
_contactPerson.ContactForParty = _oppTable.Party;
_contactPerson.MainResponsibleWorker = _oppTable.OwnerWorker;
_contactPerson.Party = _dirPartyPersonId;
_contactPerson.Sensitivity = smmSensitivity::Normal;
_contactPerson.insert();
//Creation of Logistic information as a Parent for Email and Phone data
_logisticLocation.clear();
_logisticLocation.Description = StaggingOpportunity.Company;
_logisticLocation.insert();

//Creation of Email address detail
_logisticEAddress.clear();
_logisticEAddress.Description = “Official Email address”;
_logisticEAddress.IsPrimary = NoYes::Yes;
_logisticEAddress.Location = _logisticLocation.RecId;
_logisticEAddress.Locator = StaggingOpportunity.Email;
_logisticEAddress.PrivateForParty = _oppTable.Party;
_logisticEAddress.Type = LogisticsElectronicAddressMethodType::Email;
_logisticEAddress.insert();

//Associate the data of above data with DirPartyTable
DirPartyTable::updatePrimaryContact(_contactPerson.Party, _logisticEAddress);
//Creation of data in dirPartyLocation
_dirPartyLocation.clear();
_dirPartyLocation.IsPrimary = NoYes::Yes;
_dirPartyLocation.Location = _logisticLocation.RecId;
_dirPartyLocation.Party = _dirPartyPersonId;
_dirPartyLocation.insert();
//Creation of Phone Number detail
_logisticEAddress.clear();
_logisticEAddress.Description = “Official Phone Number”;
_logisticEAddress.IsPrimary = NoYes::No;
_logisticEAddress.Location = _logisticLocation.RecId;
_logisticEAddress.Locator = StaggingOpportunity.Contact;
_logisticEAddress.PrivateForParty = _oppTable.Party;
_logisticEAddress.Type = LogisticsElectronicAddressMethodType::Phone;
_logisticEAddress.insert();
//Update the stagging information
/* while select forUpdate _stagOpportunity
where
_stagOpportunity.RecId == StaggingOpportunity.RecId
{
_stagOpportunity.OpportunityId = _oppTable.OpportunityId ;
_stagOpportunity.IsInjected = NoYes::Yes ;
_stagOpportunity.update();
}*/

update_recordSet _stagOpportunity
setting
OpportunityId = _oppTable.OpportunityId,
IsInjected = NoYes::Yes
where
_stagOpportunity.RecId == StaggingOpportunity.RecId;

ttsCommit;
StaggingOpportunity_ds.refresh();
StaggingOpportunity_ds.refreshEx();
StaggingOpportunity_ds.reread();
}
catch
{
error(strFmt(“%1”, Exception::Error));
}
}
else
warning(“Selected record already exist in the Opportunity section.”);

//super();
}