X++ code to create customer by taking CustGroup as a input from dialog window
Code :-
class BAS_CustomerCreationDailogbox extends RunBase
{
DialogField fieldcustgroup;
CustTable custtable;
CustGroupId custgroup;
NumberSeq numberSeq;
DirParty dirParty;
DirPartyPostalAddressView dirPartyPostalAddressView;
DirPartyContactInfoView dirPartyContactInfo;
public Object Dialog()
{
//To get the fields on dialog
Dialog dialog;
dialog = super();
//set the caption for dialog field
dialog.caption("Enter CustGroup");
//add field to dailog window
fieldcustgroup = dialog.addField(extendedTypeStr(CustGroupId),"CustGroup");
return dialog;
}
public boolean getfromDialog()
{
custgroup = fieldcustgroup.value();
return super();
}
public void run()
{
ttsBegin;
custTable.initValue();
try
{
//CustTable
numberSeq = NumberSeq::newGetNum(CustParameters::numRefCustAccount());
custtable.AccountNum = numberSeq.num();
custtable.CustGroup = custgroup;
custtable.Currency ='BRL';
custtable.PaymTermId ='10DD';
custtable.PaymMode ='CHEQUE-01';
Name name = "Mr.Murgesh";
custTable.insert(DirPartyType::Person, name);
//DirParty
/* Creates a new instance of the DirParty class from an address book entity
that is represented by the custTable parameter. */
dirParty = DirParty::constructFromCommon(custTable);
dirPartyPostalAddressView.LocationName ='HeadQuarters ';
dirPartyPostalAddressView.City ='São Paulo';
dirPartyPostalAddressView.Street ='4th Avenue';
dirPartyPostalAddressView.StreetNumber ='18';
dirPartyPostalAddressView.CountryRegionId ='BRA';
dirPartyPostalAddressView.State ='SP';
// Fill address
dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);
dirPartyContactInfo.LocationName ='SouthStreet Contact Phone';
dirPartyContactInfo.Locator ='550291165342';
dirPartyContactInfo.Type = LogisticsElectronicAddressMethodType::Phone;
dirPartyContactInfo.IsPrimary = NoYes::Yes;
// Fill Contacts
dirParty.createOrUpdateContactInfo(dirPartyContactInfo);
Info(strFmt("%1, %2, %3, %4", custTable.AccountNum, custTable.CustGroup, custTable.PaymMode, custTable.Currency));
// Marks the end of transaction.
ttsCommit;
}
catch(Exception::Error)
{
ttsAbort;
throw error("can't create customer");
}
}
public static void main(Args _args)
{
BAS_CustomerCreationDailogbox custgrp = new BAS_CustomerCreationDailogbox();
if(custgrp.prompt())
{
custgrp.run();
}
}
}
Comments
Post a Comment