Posts

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