Showing posts with label Tricks and Tool. Show all posts
Showing posts with label Tricks and Tool. Show all posts

May 02, 2020

How to get tableId of tables in D365FO

Hi Folks,

Now when we don't have the leverage of Jobs any more and if you need quick result when you are dealing with multiple tables, try below to get table Id

Option 1: D365FO browser
http://<Environment link>/?cmp=<LegalEntity>&mi=SysTableBrowser&TableName=SysTableIdView

Option 2: SQL server management studio
Run below query

select * from SysTableIdView

Of course, you can filter your queries based on your requirements. 


-Harry Follow us on Facebook to keep in rhythm with us. https:fb.com/theaxapta

December 30, 2019

[LogicApps/Flow] Odata operators for Odata query

[Updated on September 8, 2020]
Hi Folks,

While working on Logic apps and Flow we need to apply a different filter on Odata query to get the desired data from an Odata entity. Below are the most used operators to use in an Odata query with example. 

The operators supported in the expression language are shown in the following table.

Operator
Description
Example
Logical Operators
Eq
Equal
/Suppliers?$filter=Address/City eq 'Redmond'
Ne
Not equal
/Suppliers?$filter=Address/City ne 'London'
Gt
Greater than
/Products?$filter=Price gt 20
Ge
Greater than or equal
/Products?$filter=Price ge 10
Lt
Less than
/Products?$filter=Price lt 20
Le
Less than or equal
/Products?$filter=Price le 100
And
Logical and
/Products?$filter=Price le 200 and Price gt 3.5
Or
Logical or
/Products?$filter=Price le 3.5 or Price gt 200
Not
Logical negation
/Products?$filter=not endswith(Description,'milk')
Arithmetic Operators
Add
Addition
/Products?$filter=Price add 5 gt 10
Sub
Subtraction
/Products?$filter=Price sub 5 gt 10
Mul
Multiplication
/Products?$filter=Price mul 2 gt 2000
Div
Division
/Products?$filter=Price div 2 gt 4
Mod
Modulo
/Products?$filter=Price mod 2 eq 0
Grouping Operators
( )
Precedence grouping
/Products?$filter=(Price sub 5) gt 10

For details refer below link 


-Harry Follow us on Facebook to keep in rhythm with us. https:fb.com/theaxapta

This post is referring to https://www.odata.org/.


October 24, 2019

Create and save a csv/text file in D365FO (x++ code sample)

Hi Folks,

Let's see how to create a CSV or TXT file through X++ code and later save that on local folder.




In code there is the full syntax of File::SendStringAsFileToUser method with all parameters. However, not all of them are mandatory but it's nice if you can explore them for your solution, for eg. changing the file encoding.

-Harry Follow us on Facebook to keep in rhythm with us. https:fb.com/theaxapta

July 08, 2019

[Solved] Issue with default app in Windows 10, TWINUI bug

Known Bug in Windows 10,

Error:
All sudden all my default app have been changed to TWINUI and I am not even able to change it.

























Solution: 
Open Power shell as admin and run below command,
Get-AppXPackage | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml”}






























That's it, now check the default apps again

























Also, you can Try below steps for Photo/Images
  1. Press Windows button + R.
  2. Type:%appdata%\..\Local\Packages\Microsoft.Windows.Photos_8wekyb3d8bbwe\LocalState
  3. Delete all the contents of that folder.
  4. Restart the computer and check if the issue persists.

Thanks





-Harry
Follow us on Facebook to keep in rhythm with us. https:fb.com/theaxapta

May 01, 2019

'RunAs' method in Dynamics 365 FO

Hi Folks,

Most of us have used RunAs earlier and it has the same use in D365Fo as well. Sometimes we came across where we need to run a specific business operation under a different user account than the currently logged-in user. To achieve this we can use RunAs to execute a specific operation. This enables the caller to run an X++ method in the security context of another user. This function is most often used with batch processing or workflow submission for another user.

The syntax is really simple as below,

container runAs(
        str userId,
        int classId,
        str staticMethodName
        [,
        container params,
        str company,
        str language,
        str partition
        ])

Parameter
Description
userId
The user to impersonate.
classId
The class to invoke in the impersonated session.
staticMethodName
The class method to invoke in the new user context.
params
The parameters to pass to the method; optional. 
company
The company that is selected for the impersonated session; optional.
language
The language that is selected for the impersonated session; optional.
partition
The partition key of the type that is returned by the getCurrentPartitionfunction; optional.

Now, let's see how to implement it and take an example of submitting a PR for a different user.

I need to submit a Purchase requisition on behalf of the different user through X++ code. To get this done I need a few details all in a single container type parameter



Hope it will help.

Cheers!!!
-Harry Follow us on Facebook to keep in rhythm with us. https:fb.com/theaxapta

March 01, 2019

Give method name on a range of AOT Query instead of value

Hi Guys,

Here is a quick tip, how to add methods in an AOT query ranges instead of values. Refer standard query 'CaseListPages_MyOpenCases'


https://www.theaxapta.com/
https://www.theaxapta.com/












-Harry Follow us on Facebook to keep in rhythm with us. https:fb.com/theaxapta

February 08, 2019

How to get QueryRange from Query object X++

Hi Folks,

This post is about how to get QueryRange from a query object in x++ code. This is very useful when you have to pass a query on another object and perform a certain operation based on this query and its ranges.

To understand this code sample better, let's take a scenario. On FormA I have to build a query (OR use AOT query) on run time based on certain ranges. When the user clicks on a button system will pass this query to FormB and on FormB we have to use this query and its ranges to perform other sets of operations.

Now let's see the code, which may need to write on Form B to take a query as a parameter and fetch the ranges and its values in code.



I hope this will help.

-Cheers!!!
Harry
PS: My VM is down for some reason and I couldn't prove the code and have to write it manually so you might get some syntax issues in the above code.

December 13, 2018

[Solved]Error while code check-in in visual studio ‘Could not find file….’


Hi Folks,
Here is a quick trick. I was trying to check-in a few objects in a solution and encounter a strange error.

Error:
Could not find file 'C:\Users\Adminbefabcsd4\Documents\Visual Studio 2015\Projects\<MySolution>\<MyProject>\<MySolution>.btproj

Possible reason: If you are trying to check-in your object along with the solution file, you might get this error.

Possible solution: I cannot say it a permanent fix as I didn't find any technical reason for this, but below fix worked for me.
If you didn't make any changes in the solution itself, like adding/deleting a file, you should not include solution file in included changes. Remove solution file and check-in only object which you actually made changes.

Cheers!!!
Harry

December 11, 2018

Create delivery address run time

Folk,

Here is quick code to create the delivery address on runtime. You can use this on Purchase Requisition, Purchase order or a person.
So we are going to use LogisticsPostalAddressEntity to get the right address with a new one or an existing one. This code should also handle if there is any update in any existing record by updating effective date stamp.

Have a look on below code,



Give a try and share your feedback.

Cheers!!!
Harry.

April 10, 2018

Task recorder in Dynamics 365 For Finance and Operations–Part I

Hi Folks,

Today lets see how to use the task records in new Dynamics 365 FO. Task recorder in D365FO has been re-built from the ground up with a focus on high-responsiveness, a flexible extensibility API, and seamless integrations with consumers of business process recordings. Task recorder is able to record the steps from user action in the excatly same sequence, like a wizard recording.
In this post, I’m going to use task recorder for one of D365FO process. Follow the below steps,

1: In the right corner of the app, Go to setting button and select Task Recorder
clip_image001

2. Task recorder menu contain many options here to choose
clip_image002

Below is the brief description of each option, In this post We will discuss the first two option. I will back soon with the rest two options.
image

3. For this example, we will select ‘Create recording’ and will create a new file using this task recorder. To make it simple let's start with a Purchase order
clip_image003

4. Now once you click on the start button, the system will start to capture your activity on the application. As you keep processing your purchase order, the system will record your steps
clip_image004

5. Once you have done with you the PO process, click on the stop button, System will show a further option
clip_image005

image

‘Save to this PC'’: This option allows you to save the recording on the local file system with extension ‘axtr’. Which can be used later on with AX to repeat all steps in wizard mode.

Export to Word document: System will create a word document as below format
clip_image010

Save as developer recording: the system will save an XML file to local. On top of your window, you will found one lock/Unlock option to

6. To use the saved file at later point of time, here we need the second option as describe in the above table, i.e. ‘Play recording as Guide’. Click on Play recording as a guide from task recorder menu option.
clip_image006
clip_image007

8.  Click on Open file from this PC
clip_image008

9.Browser your file and open Task guide and click on start button.
clip_image009

it will start a guide for you to walk you thoroughly on the recorded process.
clip_image011

In coming post, we will see remaining two option and the task Recorder integration with the Lifecycle Services BPM tool. Stay connected.

Cheers
Harry

June 01, 2017

X++ code for Product image upload in AX

Hi Folks,

In my previous post, I shared the test code to upload bulk images in AX through X++ code. Here is another set of code to achieve the same. Create a new class with the below methods.



Cheers
Deepak

May 23, 2017

How to enable ARM for D365 deployment

Hi Folks,

Many of us trying to deploy the new D365 environment using LCS and Azure, but due to ARM configuration we face below issue, 





Issue: Lifecycle Services can't connect to the Azure subscription using Azure Resource Manager. Click the Microsoft Azure Settings button and edit the selected Connector to provide the required permissions to ERP applications in your Azure subscription. If the issue persists, please contact support with this Id: da1c591d-7360-413c-b370-b51ec1ddef2b

Here are some good links on how we can fix this issue once for all, 


Hope this will help.
Thanks
Harry


April 07, 2016

Hide ENUM values at run time [AX-2012]

Hi Folks,
Here is code sample to hide ENUM elements from a FORM at run time.  For reference purpose I’m using SalesTable.BankducmentType (ENUM = BankDocumentType) field which contain below four elements
1. None
2. LetterOfCredit
3. ImportCollection
4. LetterOfGuarantee
image
Now i want to show only first two values while selecting on SO, to achieve this override the form control method as below

public void enter()
{
    super();
    this.delete(enum2str(BankDocumentType::LetterOfGuarantee));
    this.delete(enum2str(BankDocumentType::ImportCollection));   
}


Save your changes and, Now run your form and you will get desired values only.
image

-Harry

November 16, 2015

Use one table for creating multiple relation

Hi Folks,
After a long time I’m writing this new post.
Requirement: I need to use the single table to add multiple relation on a table. For eg. I have a parent table Table1 with field ItemId and ProcessItem. Now I need to add relation to InventTable to both fields. Hence I have to create two relation with InventTable.

How to do: Add two new relation in your table as shown below.

image
You might get an error message after this,
'RelatedTableRole' conflicts with another 'RelatedTableRole' on relation InventTable_Item on table ProcessedItemTable.
image
Solution to this error:
Set below two properties to each relation
1. UseDefaultRoleNames- set it to “NO”
2. Role: Give any logical name here, for eg. “Item”

image
image
Now compile your table, error must gone.
Write your any query/feedback in comment box and help us to improve. Thanks..!!!
-Harry

June 01, 2015

Error while Confirming PO, and in Sales Order

Hi Folks,

After applying one HotFix, I got many weird issues, some are mentioned below

1. I wasn't able to confirm any Purchase Order
2.Not able to proceed Sales order to Warehouse.
3.While packing slip of Sales Order, I am getting many lines of different sales order.

Below error message bother me every time.



Solution:
All you need to do, unmark the below check box from





Now all above error message must not come again.
To do this for all user in one shot, use below job to do it. 

static void theAxaptaUpdate(Args _args)
{
    UserInfo        UserInfo;
    update_recordSet UserInfo
    setting
    debugInfo = 1036
    where UserInfo.debugInfo == 12;
}

-Harry

Follow us on facebook to keep in  rhythm with us. @Facebook

May 28, 2015

Copy AX DB from one domain to other domain

Hi Folks,

Many time we need to restore one Database to another system which is not part of current domain. In such cases its not going to be straight forward to click on restore button on SQL. You need to perform some other action to make it work. 
  Use below steps to restore AX DB from a different Domain.

1. Restore DB using SQL management studio.
2. Edit UserInfo table in SSMS (SQL server management Studio).
you need to update the SID and domain. To find current system user SID use below steps.
SID of current system user:
Run below command in Command prompt.
whoami /user
image

You can also copy if from Registry
Type RegEdit in run command



3. Open SSMS, open AX database-> Tables -> SysUserInfo

Update below field in 
i. UserId
ii. Domain
iii. SID

4. Now start AOS services and open ax client. It should work.

-Harry