Sunday, 15 April 2018
Monday, 9 April 2018
Monday, 19 March 2018
Get Email for Customer / Vendor (with specific roles)
To get an email address for a customer or vendor, you can use the following statement
static void Cust_emailStmtjob(Args _args)
{
CustTable cust; //Replace with vendTable for Vendors
DirPartyLocation dirPartyLocation;
LogisticsElectronicAddress elecAddress;
LogisticsElectronicAddressRole elecAddressRole;
LogisticsLocationRole locRole;
select firstOnly cust
where cust.AccountNum == 'us-001';
while select DirPartyLocation
where dirPartyLocation.party == cust.Party
{
while select elecAddress
where elecAddress.Location == dirPartyLocation.Location
&& elecAddress.Type == LogisticsElectronicAddressMethodType::Email
{
while select elecAddressRole
where elecAddressRole.ElectronicAddress == elecAddress.RecId
join locRole
where locRole.RecId == elecAddressRole.LocationRole
&& locRole.Name == "Invoice"
{
info(strFmt("%1 - %2", elecAddress.Locator, locRole.Name));
}
}
}
}
static void Cust_emailStmtjob(Args _args)
{
CustTable cust; //Replace with vendTable for Vendors
DirPartyLocation dirPartyLocation;
LogisticsElectronicAddress elecAddress;
LogisticsElectronicAddressRole elecAddressRole;
LogisticsLocationRole locRole;
select firstOnly cust
where cust.AccountNum == 'us-001';
while select DirPartyLocation
where dirPartyLocation.party == cust.Party
{
while select elecAddress
where elecAddress.Location == dirPartyLocation.Location
&& elecAddress.Type == LogisticsElectronicAddressMethodType::Email
{
while select elecAddressRole
where elecAddressRole.ElectronicAddress == elecAddress.RecId
join locRole
where locRole.RecId == elecAddressRole.LocationRole
&& locRole.Name == "Invoice"
{
info(strFmt("%1 - %2", elecAddress.Locator, locRole.Name));
}
}
}
}
Add field on Purchase order confirmation report
Add field on Purchase order confirmation report
There is requirement to add field on PO lines and same for the
confirmation report. It’s not the straight away to add field on the report. It
requires to add field on other objects (table/view/query).
On PurchPurchaseOrderreport
it uses the PurchLineALLVersionsview
to get the details of the PO on the PurchPurchaseOrderDP. So follow the below
steps to add field on PurchLineAllVersions view.
- Add field on the PurchLine Table
- Add field on the PurchLineHistory Table
- Now, Refresh or Restore the queries used for PurchLineArchivedVersions and PurchLineNotArchivedVersions as this have dynamics field property to “Yes” our new fields should be added automatically on this queries and Verify the field is added on the query.
- Now, Restore the views PurchLineArchivedVersions and PurchLineNotArchivedVersions( if you want add field on the views)
- Add field on PurchLineAllVersion, here you have to add field manually as the dynamics field property is set.
- That’s it, now use the field on the PurchPurchaseOrderDP to have on report. You also have to add field on tmp table.
Friday, 23 February 2018
Export data from AX to XML file
Class Declaration:
class CustomerExportXML
{
}
Main Method:
public static void main(Args _args)
{
XmlDocument doc;
XmlElement nodexml;
XmlElement nodeTable;
XmlElement nodeAccountNum;
XmlElement nodeCustGroupId;
XmlElement nodeName;
CustTable custTable;
DirPartyTable dirPartyTable;
DirParty dirParty;
MethodInfo methodInfo;
#define.filename(@'D:\Temp\TestXML.xml')
doc = XmlDocument::newBlank();
nodexml = doc.createElement('xml');
doc.appendChild(nodexml);
while select party, AccountNum, CustGroup from custTable join dirPartyTable
//where custTable.party == DirPartyTable.RecId
{
nodeTable = doc.createElement(tableStr(CustTable));
nodeTable.setAttribute(fieldStr(CustTable, RecId),int642str(custTable.RecId));
nodexml.appendChild(nodeTable);
nodeAccountNum = doc.createElement(fieldStr(CustTable, AccountNum));
nodeAccountNum.appendChild(doc.createTextNode(custTable.AccountNum));
nodeTable.appendChild(nodeAccountNum);
nodeCustGroupId = doc.createElement(fieldStr(CustTable, CustGroup));
nodeCustGroupId.appendChild(doc.createTextNode(custTable.CustGroup));
nodeTable.appendChild(nodeCustGroupId);
Commented Line Starts
//nodeName = doc.createElement(fieldStr(dirPartyTable, Name));
//nodeName.appendChild(doc.createTextNode(custTable.name()));
//nodeTable.appendChild(nodeName);
Commented Line Ends
nodeName = doc.createElement("Name");
nodeName.appendChild(doc.createTextNode(CustTable.name()));
nodeTable.appendChild(nodeName);
}
doc.save(#filename);
info(strFmt("File %1 created.", #filename));
}
class CustomerExportXML
{
}
Main Method:
public static void main(Args _args)
{
XmlDocument doc;
XmlElement nodexml;
XmlElement nodeTable;
XmlElement nodeAccountNum;
XmlElement nodeCustGroupId;
XmlElement nodeName;
CustTable custTable;
DirPartyTable dirPartyTable;
DirParty dirParty;
MethodInfo methodInfo;
#define.filename(@'D:\Temp\TestXML.xml')
doc = XmlDocument::newBlank();
nodexml = doc.createElement('xml');
doc.appendChild(nodexml);
while select party, AccountNum, CustGroup from custTable join dirPartyTable
//where custTable.party == DirPartyTable.RecId
{
nodeTable = doc.createElement(tableStr(CustTable));
nodeTable.setAttribute(fieldStr(CustTable, RecId),int642str(custTable.RecId));
nodexml.appendChild(nodeTable);
nodeAccountNum = doc.createElement(fieldStr(CustTable, AccountNum));
nodeAccountNum.appendChild(doc.createTextNode(custTable.AccountNum));
nodeTable.appendChild(nodeAccountNum);
nodeCustGroupId = doc.createElement(fieldStr(CustTable, CustGroup));
nodeCustGroupId.appendChild(doc.createTextNode(custTable.CustGroup));
nodeTable.appendChild(nodeCustGroupId);
Commented Line Starts
//nodeName = doc.createElement(fieldStr(dirPartyTable, Name));
//nodeName.appendChild(doc.createTextNode(custTable.name()));
//nodeTable.appendChild(nodeName);
Commented Line Ends
nodeName = doc.createElement("Name");
nodeName.appendChild(doc.createTextNode(CustTable.name()));
nodeTable.appendChild(nodeName);
}
doc.save(#filename);
info(strFmt("File %1 created.", #filename));
}
Thursday, 15 February 2018
Creating a applicant through job X++
static void CreateAplicant(Args _args)
{
HcmApplicant hcmApplicant;
DirPerson dirperson;
DirPersonName dirPersonName;
NumberSeq sequence;
HcmApplicantId applicantId;
RecId person, dirPersonRecid;
DirPartyRecId partyRecId;
Name personName;
personName = "Krishna" +" " +"kumar"+ " " + "test";
partyRecId = DirPartyTable::createNew( DirPartyType::Person, personName).RecId;
dirPersonRecId = DirPerson::find(partyRecId).RecId;
dirPersonName.FirstName = "Krishna";
dirPersonName.MiddleName = "kumar";
dirPersonName.LastName = "test";
dirPersonName.Person = dirPersonRecId;
if (dirPersonName.validateWrite())
{
dirPersonName.insert();
}
ttsbegin;
applicantId = NumberSeq::newGetNum( HRMParameters::numRefApplicantId()).num();
ttscommit;
hcmApplicant.ApplicantId = applicantId;
if(dirPersonRecId != hcmApplicant.Person)
{
hcmApplicant.Person = dirPersonRecId;
hcmApplicant.insert();
}
}
{
HcmApplicant hcmApplicant;
DirPerson dirperson;
DirPersonName dirPersonName;
NumberSeq sequence;
HcmApplicantId applicantId;
RecId person, dirPersonRecid;
DirPartyRecId partyRecId;
Name personName;
personName = "Krishna" +" " +"kumar"+ " " + "test";
partyRecId = DirPartyTable::createNew( DirPartyType::Person, personName).RecId;
dirPersonRecId = DirPerson::find(partyRecId).RecId;
dirPersonName.FirstName = "Krishna";
dirPersonName.MiddleName = "kumar";
dirPersonName.LastName = "test";
dirPersonName.Person = dirPersonRecId;
if (dirPersonName.validateWrite())
{
dirPersonName.insert();
}
ttsbegin;
applicantId = NumberSeq::newGetNum( HRMParameters::numRefApplicantId()).num();
ttscommit;
hcmApplicant.ApplicantId = applicantId;
if(dirPersonRecId != hcmApplicant.Person)
{
hcmApplicant.Person = dirPersonRecId;
hcmApplicant.insert();
}
}
Subscribe to:
Posts (Atom)