Import - Export Model Dynamic AX 2012
See document:
Technical Consultant
////// extesion of SrsReportRunPrinter /// [ExtensionOf(classStr(SrsReportRunPrinter))] final class LAW_SrsReportRunPrinter_C_Extension { public SrsReportDataContract dataContract; public PurchPurchaseOrderContract purchPOContract; public str buildEmalBody(PurchId _purchID) { PurchTable purchTable = PurchTable::find(_purchID); PurchTotals purchTotals; str emailHeader,emailBody; purchTotals = PurchTotals::newPurchTable(purchTable); purchTotals.calc(); real totalAmount = purchTotals.purchTotalAmount(); emailHeader = strFmt('Dear %1,
',purchTable.vendorName()); emailHeader += 'Good Day.
Please see attached P.O. for items to be delivered based on the Shipment date.
'; emailBody += strFmt('',_purchID, totalAmount,purchTable.DeliveryDate,InventLocation::find(purchTable.InventLocationId).Name); return emailHeader + emailBody; } ////// extens to update Purchase Id incase of docoment called from PurchPurchaseOrderContract rdp /// public void printReport() { RecId recordId; SysIMailerNonInteractive mailerFail; PurchId purchId; Object objRdp = this.reportContract.parmRdpContract(); str emailBody; if (objRdp is PurchPurchaseOrderContract) { purchPOContract = objRdp; recordId = purchPOContract.parmRecordId(); purchId = VendPurchOrderJour::findRecId(recordId).PurchId; emailBody = this.buildEmalBody(purchId); printSettings.parmEMailBody(emailBody); } next printReport(); if (mailer && mailer.emailId) { if (recordId && purchId) { SysOutgoingEmailTable outEmail = SysOutgoingEmailTable::find(mailer.emailId,true); if (outEmail) { outEmail.LawPurchId = purchId; ttsbegin; outEmail.update(); ttscommit; } if (outEmail.Status == SysEmailStatus::Failed) { str toAddress = SrsReportRunMailer::lawBuildUserEmailAddress(PurchTable::find(purchId).CreatedBy); str fromAddress = outEmail.Sender; str mess = strFmt("@LAW:LAW_G02010107_01",purchId); mailerFail = SysMailerFactory::getNonInteractiveMailer(); //send fail email back to sender var messageBuilder = new SysMailerMessageBuilder(); messageBuilder.setFrom(fromAddress) .addTo(toAddress) .addCc("") .setSubject(mess) .setBody(""); boolean result = mailerFail.sendNonInteractive(messageBuilder.getMessage()); //end } } } } }
Store name/WH name | P.O.# | P.O. Amount | Shipment/Delivery Date: |
%4 | %1 | %2 | %3 |
When refreshing a production environment to a sandbox environment, or a sandbox environment to another sandbox environment, there are certain elements of the database that are not copied over to the target environment. These elements include:
Power shell deploy all SSRS report d365 FO
Song Nghia - Technical Consultant
export interface ISelectDate { Month: Months; Date: number; Year: number; ToMonth: Months; ToDate: number; ToYear: number; } export interface IAvailableMonth { month: Months; displayText: string; } export enum Months { January = 1, February = 2, March = 3, April = 4, May = 5, June = 6, July = 7, August = 8, September = 9, October = 10, November = 11, December = 12 }
import * as Triggers from "PosApi/Extend/Triggers/PrintingTriggers"; import { ClientEntities, ProxyEntities } from "PosApi/Entities"; import { ObjectExtensions } from "PosApi/TypeExtensions"; //import ReprintReceiptCache from "../ViewExtensions/ShowJournal/ReprintReceiptCache"; //import { Entities, XZReportDocument } from "../DataService/DataServiceRequests.g"; import { GetHardwareProfileClientRequest, GetHardwareProfileClientResponse } from "PosApi/Consume/Device"; import { GetReceiptsClientRequest, GetReceiptsClientResponse } from "PosApi/Consume/SalesOrders"; import { PrinterPrintRequest, PrinterPrintResponse } from "PosApi/Consume/Peripherals"; export default class PrePrintReceiptCopyTrigger extends Triggers.PrePrintReceiptCopyTrigger { public execute(options: Triggers.IPrePrintReceiptCopyTriggerOptions): Promise{ if (ObjectExtensions.isNullOrUndefined(options)) { // This will never happen, but is included to demonstrate how to return a rejected promise when validation fails. //ABC let error: ClientEntities.ExtensionError = new ClientEntities.ExtensionError("The options provided to the PrePrintReceiptCopyTrigger were invalid."); return Promise.reject(error); } else { return this.context.runtime.executeAsync(new GetHardwareProfileClientRequest()) .then((response: ClientEntities.ICancelableDataResult ) : Promise > => { let hardwareProfile: ProxyEntities.HardwareProfile = response.data.result; // Gets the receipts. let salesOrderId: string = options.salesOrder.Id; let receiptRetrievalCriteria: ProxyEntities.ReceiptRetrievalCriteria = { IsCopy: false, IsRemoteTransaction: false, IsPreview: false, QueryBySalesId: true, ReceiptTypeValue: ProxyEntities.ReceiptType.CustomReceipt6, HardwareProfileId: hardwareProfile.ProfileId }; let getReceiptsClientRequest: GetReceiptsClientRequest = new GetReceiptsClientRequest(salesOrderId, receiptRetrievalCriteria); return this.context.runtime.executeAsync(getReceiptsClientRequest); }) .then((response: ClientEntities.ICancelableDataResult ) : Promise > => { let receipts: ProxyEntities.Receipt[] = response.data.result; // Prints the receipts. let printerPrintRequest: PrinterPrintRequest = new PrinterPrintRequest(receipts); return this.context.runtime.executeAsync(printerPrintRequest); }) } }
Get formRun, Form control, datasource and selected record from form datasource :
[FormDataSourceEventHandler(formDataSourceStr(MyForm, MyRandomTableDS), FormDataSourceEventType::Written)] public static void MyRandomTableDS_OnWritten(FormDataSource sender, FormDataSourceEventArgs e)
{
FormRun formRun = sender.formRun() as FormRun;
// you can even call custom methods
formRun.myCustomMethod();
// Get the selected datasource record
TableName tableBuffer = sender.cursor();
// Get datasource variable
FormDataSource DSVariable = sender.formRun().dataSource(“TableName”);
}
Get form datasource from xFormRun
[FormEventHandler(formStr(SomeForm), FormEventType::Initialized)] public static void SomeForm_OnInitialized(xFormRun sender, FormEventArgs e)
{
FormDataSource MyRandomTable_ds = sender.dataSource(formDataSourceStr(SomeForm, MyRandomTableDS));
…
}
Access form control from xFormRun
[FormEventHandler(formStr(SomeForm), FormEventType::Initialized)] public static void SomeForm_OnInitialized(xFormRun sender, FormEventArgs e)
{
// set the control to invisible as an example
sender.design().controlName(formControlStr(SomeForm, MyControl)).visible(false);
}
Get FormRun from form control
[FormControlEventHandler(formControlStr(MyForm, MyButton), FormControlEventType::Clicked)] public static void MyButton_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun formRun = sender.formRun() as FormRun;
formRun.myCustomMethod();
}
Get current record in form control event
[FormControlEventHandler(formControlStr(SomeForm, SomeButton), FormControlEventType::Clicked)] public static void SomeButton_OnClicked(FormControl sender, FormControlEventArgs e)
{
// as an example the datasource number is used for access; I perceive the formDataSourceStr as more robust
SomeTable callerRec = sender.formRun().dataSource(1).cursor();
}
[ExtensionOf(formstr(AssetTransfer))] final class LAW_AssetTransferForm_Extension { void init() { next init(); LAW_TransferLocationTmp tmp; delete_from tmp where tmp.CreatedBy == curUserId(); AssetTable assetTable = this.args().record(); tmp.clear(); tmp.AssetId = assetTable.AssetId; tmp.fromLocation = assetTable.Location; tmp.insert(); } public void closeOk() { LAW_TransferLocationTmp tmp; select tmp where tmp.CreatedBy == curUserId(); if(tmp.ToLocation == '') { throw Error('Field To location must be filled in.'); } next closeOk(); //delete_from tmp // where tmp.CreatedBy == curUserId(); FormRun fr = this.args().caller(); fr.dataSource().research(true); } }
private void checkAssetBooksStatus() { // Copy the main datasource query Query query = new Query(assetBook_ds.query()); QueryBuildDataSource qbdsAssetBook = query.dataSourceTable(tableNum(AssetBook)); // Finding all value models NOT in Open status to provide infolog warnings. QueryBuildRange statusRange = xSysQuery::findOrCreateRange(qbdsAssetBook, fieldNum(AssetBook, Status)); statusRange.value(strfmt("%1,%2", SysQuery::valueNot(AssetStatus::Open), SysQuery::valueNot(AssetStatus::Closed))); QueryRun queryRun = new QueryRun(query); // Check if any of the selected valuemodels are Not in open status. // Show infolog warning for all such selected value models. if (SysQuery::countLoops(queryRun) > 0) { warning("@FixedAssets:FA_MessageNotification_BooksCannotBeTransferedBecauseStatusIsWrong"); while (queryRun.next()) { AssetBook localAssetBook = queryRun.get(tableNum(AssetBook)); warning(strFmt("@FixedAssets:FA_MessageNotification_AssetAndBookInformation", localAssetBook.AssetId, localAssetBook.BookId)); } } statusRange = xSysQuery::findOrCreateRange(qbdsAssetBook, fieldNum(AssetBook, Status)); statusRange.value(strfmt("%1,%2", SysQuery::value(AssetStatus::Open), SysQuery::value(AssetStatus::Closed))); //Close the form if no value models are selected that are in the Open or Closed status. if (SysQuery::countLoops(new QueryRun(query)) <= 0) { this.closeCancel(); } }