Posts

Data entity methods in d365fo

  Data entity methods in d365fo Data entity methods in d365fo. mapEntityToDataSource // This method is hitting while updating and inserting // we can assign datasource1 recid values to child data source. // public void mapEntityToDataSource(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx) { if (_entityCtx.getDatabaseOperation() == DataEntityDatabaseOperation::Insert || _entityCtx.getDatabaseOperation() == DataEntityDatabaseOperation::Update) { if (_dataSourceCtx.name() == dataEntityDataSourceStr(MyEntity, MyDataSource)) { TestCustomer testCustomer = _entityCtx.getRuntimeContextByName( dataEntityDataSourceStr(MyEntity, TestCustomer)).getBuffer(); this.CustomerRecid = testCustomer.recid; } } super(_entityCtx, _dataSourceCtx); } -------------------------------------------...

how to find error label code and hardcode Label using powershell in d365 fo x++

1.) Handling Hardcoded Error Messages While label-based error messages can be traced efficiently,  some developers might not follow best practices  and instead use  hardcoded messages  in X++ code. This makes finding the error source much harder. To quickly locate  hardcoded error messages  in X++ files, I asked  ChatGPT  to generate a PowerShell script that searches for error messages directly in the source code. Here’s the  PowerShell command  to find hardcoded error messages in all X++ files: $sourcePath = 'K:\AOSService\PackagesLocalDirectory\' $xppFiles = Get-ChildItem -Path $sourcePath -Recurse -Filter "*.xpp" $xppFiles | Select-String -Pattern 'hata' | Select Line, Filename, LineNumber This script: ✅   Scans all X++ files  under PackagesLocalDirectory.  ✅   Searches for occurrences of the word "hata"  (or any error message).  ✅   Returns the file name, line number, and matching line ,...

How to get workers current position, department and manger in X++

  In Dynamics 365 F&O, we have HcmWorkerHelper class which gives much information about worker such as department, primary position, current legal entity and so on. The code to get worker’s current position. This gives current worker record. HcmWorkerRecId hcmWorkerRecId = HcmWorker::userId2Worker(curUserId()); HcmPositionRecId hcmPositionRecId = HcmWorkerHelper::getPrimaryPosition(hcmWorkerRecId); The code to get current worker manager. HcmWorker currentWorker = HcmWorker::find(HcmWorkerLookup::currentWorker()); HcmWorker currentWorkerManager = HcmWorkerHelper::getManagerForWorker(currentWorker.RecId); The code to get current worker department. HcmWorker currentWorker = HcmWorker::find(HcmWorkerLookup::currentWorker()); OMOperatingUnit department = HcmWorkerHelper::getPrimaryDepartment(currentWorker.RecId); The code to get current worker legal entity. HcmWorker currentWorker = HcmWorker::find(HcmWorkerLookup::currentWorker()); CompanyInfo legalEntity = HcmWorkerHelper::get...

WorkFlow Resubmit Code in d365 fo x++

  public static void main(Args args) { //  TODO:  Write code to execute once work items are resubmitted.      recID recID             = args.record().RecId;      tableId tableId         = args.record().TableId;      XEN_OverTimeSummary XEN_OverTimeSummary = args.record();      WorkflowWorkItemTable workItem          = args.caller().getActiveWorkflowWorkItem();      WorkflowWorkItemActionDialog workflowWorkItemActionDialog;      if (workItem.RecId > 0)      {          try          {              workflowWorkItemActionDialog = WorkflowWorkItemActionDialog::construct( workItem, WorkflowWorkItemActionType::Resubmit,new MenuFunction(args.menuItemName(),args.menuItemType()));       ...

Get individual Ledger Dimension displayValue in d365 fo x++

 private DimensionDisplayValue getAttributeValueFromCombination(LedgerDimensionAccount _LedgerDimensionAccount,Name _attributeName) {     DimensionAttributeLevelValueAllView dimAttrLevelAll;     DimensionAttribute                  dimAttribute;       select DisplayValue from dimAttrLevelAll     join dimAttribute     where dimAttribute.RecId                    == dimAttrLevelAll.DimensionAttribute && dimAttrLevelAll.ValueCombinationRecId == _LedgerDimensionAccount && dimAttribute.Name                     == _attributeName;     return dimAttrLevelAll.DisplayValue; }

how to get all financial dimension with pipe delemeter in d365 fo x++

     public str getAllFinancialDimensions(RecId _defaultDimension)     {         DimensionAttributeValueSetStorage dimStorage;         DimensionAttribute                 dimAttr;         DimensionAttributeValue            dimAttrValue;         DictTable                          dictTable;         Common                             common;         str                                result = '';         str                                name, value, displayV...

get LedgerDimension Values in d365 fo x++

   private str getDimensionCombinationId(LedgerDimensionAccount _ledgerDimension)   {       DimensionAttributeValueCombination  dimAttrValueComb;       DimensionStorage                    dimensionStorage;       DimensionStorageSegment             segment;       int                                 segmentCount, segmentIndex;       int                                 hierarchyCount, hierarchyIndex;       str                                 segmentName, segmentDescription;       SysDim             ...

ExecuteQuery From UAT or Produ in d365 fo x++

1). Read the given link and install in your local vm   https://github.com/TrudAX/XppTools#installation

Get Default Dimension Description in d365 fo x++

  public str getDimensionDisplayValue(DimensionDefault _dimension, Name _dimensionName)  {      str dimensionValue;      DefaultDimensionView dimensionView;      select firstonly1       dimensionView       where dimensionView.DefaultDimension == _dimension       && dimensionView.Name == _dimensionName;      return dimensionView.dimensionDiscription();;  }

How to Open multiple instances of Report at the same time using X++ code in D365 Fo

  1.) Declare contract Class 2 variales     List                  customerList;     str                   customer;     [DataMemberAttribute('customer'), SysOperationLabelAttribute("customer Account")]     public str ParmCustomer(str _customer = customer)     {         customer  =  _customer;         return customer;     }     [DataMemberAttribute('customerList'),SysOperationLabelAttribute("customer"),AifCollectionTypeAttribute("customerList", Types::String)]     public List ParmcustomerList(List _customerList = customerList)     {         customerList  =  _customerList;         return customerList;     } 2). controller class  Decalre on controller class using  System.IO.Compression...

Hide Report Parameter From contract class in d365 fo x++

Add propertiy  SysOperationControlVisibilityAttribute( false ) [DataMemberAttribute,SysOperationControlVisibilityAttribute( false )] public str parmparameter(str _buffer=buffer) { buffer     =      _buffer; return  _buffer; }

Add range on List in DP Class in d365 fo x++

   1). ItemGroup  is a list type in dp class  2). chek if the list is empty  if(!ItemGroup.empty()) 3.) Convert List into container and then comvert form list to string   if(!ItemGroup.empty())         {                 InventItemGroupItemqbds.addRange(fieldNum(InventItemGroupItem, ItemGroupId)).value(con2Str(list2Con(ItemGroup)));         }

Print SSRS Report into word documnets in d365 fo x++

    static void SaveSPITOCommercialInvoiceToWord(Args _args)     {         SPITOCommercialInvoiceController controller = new SPITOCommercialInvoiceController();         SPITOCommercialInvoiceContract contract;         WHSShipmentTable shipmentTable;         SrsReportRunImpl reportRun;         str fileName;         shipmentTable = _args.record() as WHSShipmentTable;         // Pass Args to controller         controller.parmArgs(_args);         controller.parmReportName(ssrsReportStr(SPITOCommercialInvoiceReport, Report));         // Set contract value         contract = controller.parmReportContract().parmRdpContract() as SPITOCommercialInvoiceContract;         contract.parmShipmentId(shipmentTable.ShipmentId);       ...

Arabic Class in d365 fo x++

 class HA_NumHelper {     public Description numToTxt_En(real _amount, str _currency1)     {         real decimals, WordReal;         int intNum;         str 250 word, decWord, wholeWord;         int repPos, repPos1, repPoswhole;         word = Global::numeralsToTxt_EN(_amount);         repPos = strscan(word, ' and', 1, strlen(word));         intNum = _amount;         decimals = _amount - intNum;         WordReal = _amount - decimals;         if (decimals == 0.00)         {             wholeWord = num2str(WordReal,0,0,0,0);             wholeWord = Global::numeralsToTxt_EN(str2num(wholeWord));             wholeWord = strdel(wholeWord, 1, 4);     ...

jumpRef method to open one form to another form in d365 fo x++

Steps:    Create a method in Table and take the specific id to the parameter  public static void jumpRefId(ContractID _ContractID)     {         Args            args = new Args();         MenuFunction    menuFunction;         PersonContracts PersonContracts;         select * from PersonContracts         where PersonContracts.PersonId == _ContractID;         args.record(PersonContracts);         args.lookupRecord(PersonContracts);         menuFunction = new MenuFunction(menuitemDisplayStr("Menuitemname"), MenuItemType::Display);         menuFunction.run(args);     } step 2: call this method in form field method jumpref()  [Control("String")]     class DSPPersonContracts_PersonId     {         ...

Form datasource Event Handler in d365 fo x++

  Datasource event handler: Written: // Datasource - event handler for written     [ FormDataSourceEventHandler ( formDataSourceStr ( FormName , DataSourceName),  FormDataSourceEventType ::Written)]      public   static   void  DataSourceName_OnWritten( FormDataSource  sender,  FormDataSourceEventArgs  e)     {          FormRun          form              = sender.formRun();          FormDataSource   DatasourceName_ds = form.dataSource( formDataSourceStr ( FormName , DataSourceName))  as   FormDataSource ;          TableName        buffTable         = Datasourc...