Skip to content

Instantly share code, notes, and snippets.

View d47447's full-sized avatar

Deepak Agarwal d47447

View GitHub Profile
@d47447
d47447 / IItemImageImportMethod2
Created March 1, 2019 10:03
X++ class to import item images
class ImageImport extends RunBase
{
ItemIdEANExternalItemIdRadio itemIdEANExternalItemIdRadio;
// Packed variables
FilePath filePath;
NoYesId setDefault;
VendAccount vendAccount;
// Dialog fields
@d47447
d47447 / ExportLicenseFile
Created March 15, 2019 03:43
Export license file from AX 2009, and 2012
static void OutputLicenseToText(Args _args)
{
#define.licenseVersion(2)
#define.KeywordLen(20)
#define.keywordLicense('License')
#define.keywordProperties('Properties')
#define.keywordCodes('Codes')
#define.keywordCodeLine('CodeLine')
#define.keywordDate('Date')
#define.keywordSerial('Serial')
@d47447
d47447 / RunAs
Created May 1, 2019 09:36
PR workflow submission RunAs method
WorkflowUser submitUser = DirPersonUserEx::worker2UserId(purchReqTable.Originator);
container parm = [workFlowTypeStr(PurchReqReview), purchReqTable.RecId, wfComment, NoYes::No, submitUser];
RunAs(submitUser, classNum(myClass), staticMethodStr(myClass, SubmitToWorkflow), parm);
CodeAccessPermission::revertAssert();
//While in myClass method SubmitToWorkflow will contain below code.
@d47447
d47447 / CreateVendorContactRecord
Created July 23, 2019 08:58
Create a contact for the vendor
private void createContact(VendorRequestCreate _vendorRequestCreate, RefRecId _partyId)
{
ContactPerson contactPerson;
DirPersonName lDirPersonName;
DirPerson lDirPerson;
DirParty lDirParty;
LogisticsLocation lLogisticsLocation;
DirPartyContactInfoView lDirPartyContactInfoView;
;
@d47447
d47447 / CreateVendorPostalAddress
Created July 23, 2019 09:03
Create vendor postal address
public void createPostalAddress(VendorRequestCreate _vendorRequestCreate)
{
VendorRequestAddress vendorRequestAddress;
DirPartyPostalAddressView dirPartyPostalAddressView;
;
select Addressing,
LogisticsAddressCity,
LogisticsAddressCountryRegionId,
LogisticsAddressStateId,
@d47447
d47447 / MultipleTableInLookUp
Created July 27, 2019 22:36
How To use Multiple Tables in Form LookUp
public void lookup()
{
Query query = new Query();
QueryBuildDataSource qbdsPurchTable,QbdsInvntQO, qbdsInventDim;
QueryBuildRange qbrVendId,qbrPurchStatus,qbrPurchType;
QueryBuildLink qblink1, QbLink2;
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(PurchTable), this);
;//breakpoint;
qbdsPurchTable = query.addDataSource(tableNum(PurchTable));
@d47447
d47447 / CreateTxtCsvFile
Created August 7, 2019 08:43
Create and save a csv/text file in D365FO (x++ code sample)
System.IO.Stream stream;
TextStreamIo io;
System.IO.StreamReader reader;
XML fileContent;
io = TextStreamIo::constructForWrite();
io.writeExp(str2con(<String value/record>)));
stream = io.getStream();
stream.Position = 0;
@d47447
d47447 / setStringLength
Created August 7, 2019 10:45
Set string lenght required by PTX file format and upper case
/// <summary>
/// Set string lenght required by PTX file format and upper case
/// </summary>
/// <param name = "_input"> Input string value</param>
/// <param name = "_desireLenght"> Required string lenght</param>
/// <returns></returns>
public String255 setStringLength(String255 _input, int _desireLenght)
{
String255 outputString;
Severity Code Description Project File Line Suppression State
Error \n\nException message: System.Data.SqlClient.SqlException (0x80131904): Column name or number of supplied values does not match table definition. 0
Error at Microsoft.Dynamics.AX.Framework.Database.Synchronize.InitialSchemaSync.RunSync() 0
Error WHEN JMAP.SKUNAME = 'Retail' AND RL.MAINTAINLICENSE = 4 THEN 10 0
Error RL.VIEWLICENSE 0
@d47447
d47447 / TableEventMethod
Created April 20, 2022 10:50
TableEventMethods
class Dpk_VendTableEventHandlerClass
{
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[DataEventHandler(tableStr(VendTable), DataEventType::InitializedRecord)]
public static void VendTable_onInitializedRecord(Common sender, DataEventArgs e)