Quantcast
Channel: Axapta V/s Me
Viewing all 341 articles
Browse latest View live

X++ code for Product image upload in AX

$
0
0
Hi Folks, 

In my previous post I shared 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 below methods. 

 class ImageImport extends RunBase  
{
// Packed variables
FilePath filePath;
NoYesId setDefault;
ItemIdEANExternalItemIdRadio itemIdEANExternalItemIdRadio;
VendAccount vendAccount;
// Dialog fields
DialogField dlgfilePath;
DialogField dlgsetDefault;
DialogField dlgitemIdEANExternalItemIdRadio;
DialogField dlgVendAccount;
#define.CurrentVersion(1)
#define.Version1(1)
#localmacro.CurrentList
filePath
,setDefault
,DMItemIdEANExternalItemIdRadio
,vendAccount
#endmacro
}
public Object dialog()
{
DialogRunbase dialog = super();
dlgfilePath = dialog.addFieldValue(extendedTypeStr(FilePath),filePath);
dlgsetDefault = dialog.addFieldValue(extendedTypeStr(NoYesId),setDefault);
dlgsetDefault.label(@SYS132677);
dlgitemIdEANExternalItemIdRadio = dialog.addFieldValue(extendedTypeStr(itemIdEANExternalItemIdRadio),itemIdEANExternalItemIdRadio);
dlgvendAccount = dialog.addFieldValue(extendedTypeStr(VendAccount),vendAccount);
dlgvendAccount.enabled(NoYes::No);
return dialog;
}
public void dialogPostRun(DialogRunbase tmpdialog)
{
//this method is needed to make the vendor field editable if externalitem is choosen.
super(tmpdialog);
tmpdialog.dialogForm().formRun().controlMethodOverload(true);
tmpdialog.dialogForm().formRun().controlMethodOverloadObject(this);
}
public boolean fld3_1_modified()
{
if(dlgitemIdEANExternalItemIdRadio.value() == DMItemIdEANExternalItemId::ExternalItemId)
{
dlgVendAccount.enabled(NoYes::Yes);
}
else
{
dlgVendAccount.enabled(NoYes::No);
}
return NoYes::Yes;
}
public boolean getFromDialog()
{
;
filePath = dlgfilePath.value();
setDefault = dlgsetDefault.value();
itemIdEANExternalItemIdRadio = dlgitemIdEANExternalItemIdRadio.value();
vendAccount = dlgvendAccount.value();
return super();
}
private ItemId getItemIdFromEAN(ItemBarCode _itemBarcode)
{
InventItemBarcode inventItemBarcode;
select firstonly ItemId from inventItemBarcode
where inventItemBarcode.itemBarCode == _itemBarcode;
return inventItemBarcode.itemId;
}
private ItemId getItemIdFromExternalItemId(ExternalItemId _externalItemId, VendAccount _vendAccount)
{
CustVendExternal custVendExternalItem;
Select firstonly ItemId from custVendExternalItem
where custVendExternalItem.ExternalItemId == _externalItemId
&& custVendExternalItem.CustVendRelation == _vendAccount
&& custVendExternalItem.ModuleType == ModuleInventPurchSalesVendCustGroup::Purch;
return custVendExternalItem.ItemId;
}
void insertImage(ItemId _itemId, Filename _fileName, NoYes _defaultImage = NoYes::No)
{
InventTable inventTable = inventTable::find(_itemid);
DocuRef docuRef;
EcoResProductImageManagement ecoResProductImageManagement;
DocuType docuType = DocuType::find('ItemImage'); //TODO: set the documenttype you provided for images
DocuActionArchive docuActionArchive = new docuActionArchive();
EcoResProductImage ecoResProductImage;
try
{
//create docuref
docuRef.clear();
docuRef.initValue();
docuRef.TypeId = docuType.TypeId;
docuRef.RefCompanyId = curExt();
docuRef.RefTableId = inventTable.TableId;
docuRef.RefRecId = inventTable.RecId;
docuRef.Name = _fileName;
docuRef.Restriction = DocuRestriction::External;
if(docuRef.validateWrite())
{
docuRef.insert();
if(setDefault == NoYes::Yes)
{
//making sure all other images are NOT standard, as only one can be standard image.
update_recordSet ecoResProductImage
setting DefaultImage = NoYes::No
where ecoResProductImage.RefRecord == docuRef.RefRecId;
}
}
ttsBegin;
docuActionArchive.add(docuRef,_fileName);
ttsCommit;
// For Image management purpose. - Start
ecoResProductImageManagement = EcoResProductImageManagement::construct();
ecoResProductImageManagement.setEcoResImageValues(docuRef, EcoResProductImageUsage::External, setDefault);
//Delete imported file
new InteropPermission(InteropKind::ClrInterop).assert();
WinAPI::deleteFile(_fileName);
CodeAccessPermission::revertAssert();
}
catch
{
throw error(strFmt('Error with Image of item: %1', _itemId)); //TODO: make a label out of this string
}
}
public container pack()
{
return [#CurrentVersion,#CurrentList];
}
public void run()
{
FileSystemAdapter fileSystemAdapter;
str imageFileName;
ItemId itemId;
;
fileSystemAdapter = FileSystemAdapter::construct(filePath);
while (fileSystemAdapter.nextFile())
{
itemId = '';
switch(itemIdEANExternalItemIdRadio)
{
case itemIdEANExternalItemId::ItemId :
itemId = fileSystemAdapter.fileNameWithoutExtension();
break;
case itemIdEANExternalItemId::EAN :
itemId = this.getItemIdFromEAN(fileSystemAdapter.fileNameWithoutExtension());
break;
case itemIdEANExternalItemId::ExternalItemId :
if(vendAccount != '')
{
itemId = this.getItemIdFromExternalItemId(fileSystemAdapter.fileNameWithoutExtension(),vendAccount);
break;
}
default : itemId = '';
}
imageFileName = fileSystemAdapter.fullFileName();
if(itemId != ''&& imageFileName != ''&& InventTable::exist(itemId))
{
this.insertImage(itemId,imageFileName, setDefault);
}
}
}
public boolean unpack(container packedClass)
{
Version version = RunBase::getVersion(packedClass);
;
switch (version)
{
case #CurrentVersion:
[version,#CurrentList] = packedClass;
break;
default:
return false;
}
return true;
}
server static ImageImport construct()
{
return new ImageImport();
}
static void main(Args args)
{
ImageImport ImageImport = ImageImport::construct();
if (ImageImport.prompt())
ImageImport.run();
}

How to setup Item coverage in Dynamics 365 FO

$
0
0
While performing some inventory transaction or MRP you may get this error “Item coverage is not fully updated.". We encounter this error because of default item coverage is not available for selected item and inventory dimension. Here is step by step guide to setup the item coverage for various inventory dimension.

Go to Master planning > Setup > Item coverage and Follow below steps to setup Item coverage.

Please note: few steps may differ on the basis of your selection during the wizard.


clip_image002
clip_image004
clip_image006
clip_image008
clip_image010
clip_image012
clip_image014
clip_image016
clip_image018

Enjoy…!!!

Harry













Working time has not been specified for xx/xx/xxxx

$
0
0
Hi Folks,

While trying to release a Production order, I encountered an error,
Error: Working time has not been specified for xx/xx/xxxx when releasing production order
Solution: You need to define the working time for working time calendar. Follow below steps.


Step I: Go to Organisation administration > Setup> Calendar > Calendars

image



Step II: Select a calendar and click on Working time on action pan.
image

Step III: Click on compose working time, and select appropriate values
image

Step IV: Once done, click on OK button, you will get default working time created for the calendar.
image

Enjoy…!!!

Harry



Mobile app development in D365 for FO - Part I

$
0
0
Hi Folks,

This is my first post on mobile development, here I am going to share basic development steps (that’s doesn’t require any coding really.) J MS released a new mobile app for Android and iOS named as “Microsoft Dynamics 365 Unified Operations”, MS keep releasing new exciting feature and support in a timely manner.
1.      Download Microsoft Dynamics 365 Unified Operation app from your mobile store






2.      For the first time, you need to use your D365 application URL and valid credentials to open this app


3.      Now go to your web browser and open D365. On the right top corner select setting > Mobile App
 





4.      Your browser will split into two portions, left one for D365 web browser while right side for mobile application configuration, like below

 
5.      For this demo, let’s take an example of Customers. Click on create button


6.      We will add a new mobile workspace for Customers and a page for “All customer”


7.      You will be navigated to next screen for “All customer”, where you need to select fields for this App page. Go to Accounts receivable > All customers and click on “Select fields” in all customer page.







8.      When you click on “Select fields” on AX side “All Customer” form few fields will be highlighted, shown in below image

















9. Click on “+” sign next to each field to add them to your mobile app page. As you select these fields they will appear in right side window where you are configuring your mobile app. Once you select all your required fields click on Done.



10.On next screen, to set any further property click on Property button which is available for each selected field.


11.Now click on Back > Done > Save.
12.As a final step, you need to publish this app workspace, select your workspace and click on Publish button on top.


13.You get a system notification on the successful action.


14.I have tested this on an android device, go to your app. I hope you already logged in successfully in mobile app earlier. Now pull down the screen to refresh ( as we do in most of the mobile app like Facebook, LinkedIn, Outlook). A new workspace must appear in the app, Customers, below are the screenshots from the app.


 






Here the sequence of a field that you selected during field selection for a page is very important, we choose Customer group first than Customer account hence we got Customer group on top of each record. So, choose your fields carefully.

In next post, we will discuss how to create a new record using the mobile app. We will be continuing the same app there.

Enjoy…!!!

Thanks
Harry

How to Delete a model in Dynamics 365 for FO

$
0
0

I was trying for this for very long time, on initial stage of development it was one of the biggest headache for me. HOW TO DELTE A MODEL. So now finally I come to conclusion on this.

Note: I would recommend check with all other developer who is sharing the same dev machine before deleting this to make nothing will go wrong. Take a backup of your code.

Prerequisite:
1.     Login to server using admin credentials
2.     Check your model directory it must be sore under below path/folder
C:\AOSService\PackagesLocalDirectory/<your model>





There can be two scenarios here,
1.     Model belongs to its own package
2.     Model belongs to standard (existing) package.

1.     If your model belongs to its own package (For example: An extension package with no other models in the package):
a.      Stop the following services: The AOS web service and the Batch Management Service
b.     Delete the package folder C:\AOSService\PackagesLocalDirectory\<your model>
c.      Restart the services from step 1
d.     If Visual Studio is running, refresh your models (Visual Studio > Dynamics 365 > Model management > Refresh models)
e.      In Visual Studio, perform a full database synchronization (Visual Studio > Dynamics 365 > Synchronize database...)





2.     If your model belongs to a package with multiple models (For example, <your model> overlays Application Suite):
a.      Stop the following services: The AOS web service and the Batch Management Service
b.     Delete the model folder C:\AOSService\PackagesLocalDirectory<PackageName>\<your model> (In this example PackageName=ApplicationSuite)
c.      Restart the services from step 1
d.     In Visual Studio, refresh your models (Visual Studio > Dynamics 365 > Model management > Refresh models)
e.      In Visual Studio, build the package that the deleted models belonged to (Visual Studio > Dynamics 365 > Build models...)
f.       In Visual Studio, perform a full database synchronization (Visual Studio > Dynamics 365 > Synchronize database...)


Enjoy..
Harry.

Disc: This post is referred from here.


Mobile app development in D365 for FO- Part II

$
0
0
Hi Folks,

In my last post Mobile app development in D365 for FO - Part I, we discussed about how to create simple work space for mobile platform. In today's post i will share some of the deployment method for mobile work space.
 
In current version of mobile app, we can create two type of workspaces that are available to deployment.

a. In database
b. In metadata

a. Data base workspaces:
When user build an app workspace using web API, it will have stored in database and anyone can edit or delete such pages.

Database pages easy to create with navigation only. Mobile app framework will record user action and convert into logic, pages actually work same as user will record for it. It’s important that user have clear visibility what user require before creating a page or action.
There are three section in mobile workspace

i. Pages: Pages that will appear in mobile workspace, to display data.
ii. Action: To perform CRUD operations.
iii. Logic: Attach JS file.

Current mobile app framework is flexible in terms of designing flow, user must be very careful how user is recording the business process while configuration.

b. Metadata workspace

These pages need to be developed using classes in VS. Metadata workspaces cannot be created directly in VS, firstly user need to create a workspace in user database using above method and then attached user workspace to it.


-Harry Follow us on Facebook to keep in rhythm with us. @theaxapta

VSTS setup Dyn365FO

$
0
0
Hi Guys,

Lets see how to setup the VSTS in your LCS project and followed by how to use the VSTS version controlling for your development stuff.
Note: This post may refer some old version of D365FO, please check all available option while preforming the below steps.

1. Create a project on LCS
2. Deploy on Azure
3. On azure management portal, create a VSTS
4. Open this new link and generate a token for LCS project
5. On LCS add this VSTS and use this token
6. Authorize VSTS on LCS
7. Now need to connect this VSTS with VS
· Start Visual Studio.
· From the Team menu or Team Explorer, go to Connect to Team Foundation Server > Select Team Projects > Servers.
· Add your Team Services account ({youraccount}.visualstudio.com).
· Select your team project, and finish connecting.
image

8. Enter you TFS server name/URL
image

image

9. Now select the project that you need to connect,
image

10. For first use configure the Visual Studio
imageimage

11. Now, let's check the setting, Create a project in Visual Studio and add an object. Now Right Click on Solution click on “Add solution to Source Control”
image

12. Now let's check in the object/Change to VSTS; Again right click on Solution and select “Check in”
image

13. Enter some comment and click on Check-In
image

While prompt, confirm the check-in.

14, You must get your project in VSTS
image
Cheers,
Harry

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

$
0
0
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 stpes from user action in excatly same sequence, like a wizdard recordig.
In this post, I’m going to use task recorder for one of D365FO process. Follow below setps,

1: In the right corner of 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 first two option. I will back soon with 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 start button, the system will start to capture your action on the application. As you keep processing your purchase order, the system will record your setps
clip_image004

5. Once you have done with you the PO process, click on stop button, System will show 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 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



































Demo data module in Dynamics 365 for FO #Dyn365FO

$
0
0
Hi Folks,

In this post let discuss about the Demo Data module in Dynamics 365 for finance and operations. Let's get started with this module, how to use it, steps and the final output.

Step 1: Open you Dynamics 365 For finance and operation application and Go to Demo data module.

Step 2:  D365FO will open a new side form and ask for which process you want to create demo data, Choose all of them which you need for demo records/transactions.

Step 3: For our example lets select Demand forecasting and click OK



This process may take time depends on the volume of data

Step 4: Once this process will finish you will see the data in your Dynamics 365 for Finance and operations module.

Step 5: Now let's try to create some more demo data for another process, You can do this for all available option from the list. This time select Sales order processing and inquiry.

Step 6: Currently there are 0 records in USMF entity

Step 7: Lets run Demo data generation now

Step 8: Now you click on al sales order you will found many new records, refer below screenshot

Cheers!!
Harry

Report a production outage through Lifecycle Services [DynD365FO]

$
0
0
Hi Folks,

As we all aware LCS is a mandate now for any D365FO project with a lot of new changes/update in place. Things are slightly different now for the PROD environment where you don't have any access to servers for PROD all PROD servers are maintained by directly Microsoft.

Here is an update and I believe its an awaited update from most of our customer. Now you can report an outage for production environment straight from LCS, check below post for details;

https://blogs.msdn.microsoft.com/lcs/2017/12/18/report-production-outage-through-lcs/


Enjoy...
-Harry

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

How deploy a metadata or X++ hotfix [D365FO]

$
0
0
Hi Folks,


Here I’m going to share how to deploy a metadata or X++ hotfix using Visual Studio menu. Follow below steps to get this done. I strongly recommend using VSTS check in once hotfix deployed. Of course, you don't have RDP access other than DEV environment so this option should be for DEV servers only.
Let's start by getting into your dev machine (RDP access).


1. Open Visual studio as admin
2. GO to D365> addins
clip_image002

3. Next windows
clip_image004

Browse metadata hotfix file
clip_image006

The file must be unzipped from a folder.

4. Click on prepare button
clip_image008

You will get an info log for completion

5. Now click on apply
clip_image010

Get Infolog once complete

6. Sometimes these changes don’t come in pending changes for VSTS. In that case, you may need to add manually in VSTS branch. Go to Source control > <VSTS branch> > Metadata folder> Right click and select  “Add Items to folder”. Don’t create any folder manually, the system must create respective folders automatically when you add an item.
 clip_image012

7. Now you must check-in the code using VSTS. So same can be added in next deployment package next level environment.
8. Do a build and DB sync. Your Environment must be ready for use.


Thanks Guys, Enjoy….
Harry.

Every single eBook and video is available for just $10

Build error for new class in D365FO

$
0
0
Error: The model element was saved with unparsable source code and cannot be used. Please edit the element in Visual Studio to fix the errors: <ProjectName> (CUS) [<Modelname>]K:\AosService\PackagesLocalDirectory\bin\XppSource\<ModelName>\<ObjectName>.xpp



Possible reason: Sometimes when we rename the object name in code and manually rename the object from Solution Explorer, respective metadata still pointing to old names. Ideally, it should be another way around, rename the object in solution explorer and then just open the object it will automatically rename in class code.

Suggested Solution:
This issue doesn't fix even after DB synch and Model build. The only solution I can find for this issue is by deleting the object and create a new one. Yes, delete the object and create a new one with same code and name. This should fix this error.
Let me know if you found some other fix for the same.

Cheers
-Harry

Error: display method 'salesPcsPrice' defined on 'InventTable', referenced in data source *****

$
0
0
Hi Folks,

During some RnD on On hand inventory form, I have to duplicate the InventOnHandListPage, and while compiling this new form I was getting below error (even without any changes)

1. display method 'salesPcsPrice' defined on 'InventTable', referenced in data source 'InventTable_DS' of form '<FormName>', returns type 'Price', which is not recognized. Are you missing a module reference?
2. display method 'inventUnitId' defined on 'InventTable', referenced in data source 'InventTable_DS' of form '<FormName>', returns type 'UnitOfMeasureSymbol', which is not recognized. Are you missing a module reference?
3. display method 'purchPcsPrice' defined on 'InventTable', referenced in data source 'InventTable_DS' of form '<FormName>', returns type 'Price', which is not recognized. Are you missing a module reference?




The best solution I found for this issue, is:
Go to the method which causes this error > Check the method return type> check the respective EDT >Chcek the package.

Now chcek you model parameters if the EDT model refering to system model as well. If this model is missing in reference, add it and update the model parameter.



After model parameter update, build your model and these errors must be fixed.

Enjoy.!!
Harry

How to create default Data packages Dynamics 365 FO #DynFO365

$
0
0
Hi Folks,

Now we all know how powerful and useful is LCS for Dynamics 365 projects. There are a lot of tools to manage your project efficiently and their powerful tool helps you to manage your project well. For any project Data management (import and export) is very essentials milestone for any environment and this can surely be a time consuming and lengthy if we are not using the right tools.
Well, LifeCycle service (LCS) provides a powerful tool to manage the data import and export for a project. Configuration and data manager tool (to import data package, will cover in next post) allows selecting multiple data packages and import in any environment for a project. In this article, I will show how to create default data package in LCS asset library. This tool will help you create the default template in a sequential manner.
(However, I planed a long back to write this article but…. Winking smile I hope its never too late. )
Let's start…..
1. Login into https://lcs.dynamics.com/ using your organization credentials.
2. Select the project and go to Asset library > Process data Package; if you didn't see this tool icon on project landing page then try below
image
You can see we have only 2 files here.

3. Now to create default packages click on Import button and select a library from the list,
image

4. The above step will create a new record in process data package, it will create the data packages under ‘Data package’ tab in Asset library.
image

5. Once this process done you can go back to configuration and data manage toll you can see all the packages available here. You can download them, you can import them into any other environment. Also, you can download and fill out the data and upload them back on LCS to deploy these package on another environment.
image

Thanks all for the subjected topic, the below few details to explore further,

You can also update the Data packages (add new records, remove associate business process etc, ). To explore this go back to Asset library and click on your record and follow below steps.
image


In the next screen (Add data packages) you will see the list of all packages with sequencing number.
image

Also if you click on each package in above list in right window you will the details for the selected package.
Click on next> Next and complete this wizard.  (for this post don’t select anything on 4th step ‘Associate business process to data package’)

Cheers
Harry

Import Data Packages through LCS #Dyn365FO

$
0
0
Hi Folks,

In my last post, we discussed how to create default data packages through the Asset library. LCS is really a good tool to manage your Dynamics project. Today we will discuss one more tool Configuration and Data manager.

Demo 1:
In the first demo, we will see how to import a single data package.

Step 1. Login in LCS. Select your project.
Step 2. Got to configuration and Data management tool. Below is the landing page
1
here 1. Menu tile, to perform operations
2. Available list of data packages
3. Package details and version
4. List of entities in selected package (its blank here cause of my environment. )

Step 3. Select a package from the grid ( section 2) and click on apply (section 1). The system will ask for destination environment,
2

Step 4: Once you select a destination environment, now you have to select the company (legal entity) where you want to import this data package.
image
Select the company and hit the Apply button.

Step 5: Now you go back to your environment and navigate to Data management workspace. You can see a new project created under Data management to import this data package. You can also track the job from the same screen.

Demo 2:
The above demo applicable for single data package import. You can also select multiple data packages and import them in both Concurrently and sequentially.  Let's see how…

Step 1: Select multiple data projects (all package must belong logically same module/group)
3

Step 2: Click on Apply button and select the first option – ‘Apply concurrently’. On next screen give a tag name.
Step 3: Repeat step 3 to 5 from Demo 1.

If you select the other option ‘Apply sequentially’, the immediate next screen will ask for a sequence of data packages,
image

However, the system will give you default sequence based on name and entity contained. You can update the sequence of each package manually as well.
4

Once you set the sequence, rest steps are the same as the previous import.

I personally found this tool really helpful when a developer really need some test/setup data while development and they can not go back and forth to get dummy data. If the functional team have data in templates/Packages simple you can apply them to any dev/test box.

Try it and share your feedback.

Cheers
Harry…

Best practice (BP) warning suppression in Dynamics 365 FO #Dyn365FO

$
0
0
Hi Folks,

In this post, we will discuss how to suppression the best practice warnings while development. It's always recommended to remove/fix all best practice warnings before check-in your code to VSTS. To see all the BP warnings on your project; right click on the project and select Run Best practice Fixer on <Project name>
image

This step will show all the BP warnings for the selected project. Let's see what all the ways we have to fix these.

1. In code itself:
Add suppression line before your method,  with warning type and justification, the syntax is below
[SuppressBPWarning(‘<BPWarningType>’, <Description/Justification>.)] for example [SuppressBPWarning(‘BPParameterNotUsed’, Parameter required by the event interface.)].

This is an example for the same.

clip_image002

2. Edit Best Practice Suppression file (AxIgnoreDiagnosticList)
Every model should have a BP suppression file named AxIgnoreDiagnosticList, for system models, you can find related BP suppression file at
K:\AosService\PackagesLocalDirectory\<ModelName>\<ModelName>\AxIgnoreDiagnosticList

Right-click on your project and select ‘Edit Best practice Suppression’. For all system models, this action will open the related BP suppression file.
clip_image004

For a new model:
In case you created a new model for your development (of course you would Smile )  you have to create this file manually the first time, and on a later stage, you can amend for all BP fixes.
Create a new XML file under below path, I recommend to use a separate Visual studio instance for Create OR Edit this file.

K:\AosService\PackagesLocalDirectory\<yourModel>\<YourModel>\AxIgnoreDiagnosticList

Copy paste below

<?xml version="1.0" encoding="utf-8"?>
<IgnoreDiagnostics>
<Name>BHGSuite_BPSuppressions</Name>
<Items>
<Diagnostic>
<DiagnosticType>BestPractices</DiagnosticType>
<Severity>Warning</Severity>
<Path>dynamics://<warning path></Path> //You can get this path from warning message
<Moniker>BPParameterNotUsed</Moniker> //You can get this from error message
<Justification>FormDataSourceEventArgs e is mandatory parameter for events and not used in the current context.</Justification>
</Diagnostic>
</Items>
</IgnoreDiagnostics>

Keep adding below tag for every warning

<Diagnostic>
<DiagnosticType>BestPractices</DiagnosticType>
<Severity>Warning</Severity>
<Path>dynamics://<warning path></Path> //You can get this path from warning message
<Moniker>BPParameterNotUsed</Moniker> //You can get this from error message
<Justification>FormDataSourceEventArgs e is mandatory parameter for events and not used in the current context.</Justification>
</Diagnostic>
</Items>
</IgnoreDiagnostics>

Some recommendations:
1. Best would be to create a new file using VS and place in the respective folder. Also, while adding new records best would be to edit this file from separate VS instance rather than same solution explorer.
2. You will find the BPWarningType in the warning message. If you not sure about the justification OR if you want to make consistency with system existing BP suppression, see the standard code.
3. I recommend using a separate Visual studio instance for Create OR Edit this file.

Cheers
Harry…

Change a person on User in Dynamics 365 FO

Edit/Display or new methods on standard application objects [#Dyn365FO]

$
0
0
Hi Folks,
Let’s see how to write new method on standard application object using extension framework. An extension enables you to add functionality to existing model elements and source code.
Before starting adding new method, you need to create a new extension class for your object and this class should be declared as final and post fixed by ‘Extension’ keyword. See below example,
For Table:
[ExtensionOf(tableStr(CustTable))]
final class MyCustTable_Extension
{
<new methods>
}
For Class:
[ExtensionOf(classStr(CustExchAdj))]
final class MyCustExchAdj_Extension
{
<new methods>
}
For Form:
[ExtensionOf(formStr(VendParameters))]
final class MyVendParameters _Extension
{
<new methods>
}
Now lets see how to add different types of methods
1. New edit method
For Extension methods, the first argument in method parameter must be the object you're extending e.g. table buffer. See below code for reference;
public static edit str60 MyFieldEdit(<tableName> _this, boolean _set, name value)
{
MyTable mytable = <tablename>;
if(_set)
{
if(value)
{
ttsbegin;
custTable = CustTable::find(<tablename>.CustAccount,true);
custTable.Name = value;
custTable.update();
ttscommit;
}
}
}
2. New display method
public static display EcoResDescription productName(InventSum _this)
{
Return _this.itemName();
}
3. Normal method
In the same way you can write a new method, this method also need to be static so it can be access on form.
Public static updateSearchName(_this, Name _newName)
{
Mytable mytable = _this;
If(_newname)
{
Ttsbegin;
Mytable.searchName = _ newname;
MyTable.update();
Ttscommit;
}
}
Edit method on table extension or new methods on table extension, all method need to be static. Now to access these methods, go to your form and Add new field type of string/real/xyz. Set below property
clip_image002

Cheers,
Harry


















































Form Event handler methods in Dynamics 365 FO [#Dyn365FO]

$
0
0
Hi Guys,

Let’s discuss today the different event handlers in Dynamics 365 FO. Now we don't have the leverage 😉to overwrite existing code anymore so all you have is event handlers to manipulate standard functionality. However, event handers were available in the earlier version as an optional and best practice but now it’s the only option. I will be sharing different event handler so we can cover most of the methods with different parameters.


1. Form dataSource event hander: Here I will be using the vendTable form to get table buffer and perform additional business logic or validation.

Vendtable = Form name
vendTable = form data source name
[FormDataSourceEventHandler(formDataSourceStr(Vendtable, vendTable), FormDataSourceEventType::Written)]
public static void vendTable_OnWritten(FormDataSource sender, FormDataSourceEventArgs e)
{
    FormRun                 form           = sender.formRun();
    FormDataSource          vendTable_ds =       form.dataSource(formDataSourceStr(Vendtable,Vendtable)) as FormDataSource;
   Vendtable     Vendtable= vendTable_ds.cursor();
<Now to got table buffer, perform business logic/validation>
}
lets see one more example below;

2. Form DataSource while closing the form (same will apply for OnInitialized,
[FormEventHandler(formStr(EcoResAttributeValue), FormEventType::Closing)]
public static void EcoResAttributeValue_OnClosing(xFormRun sender, FormEventArgs e)
{
     FormDataSource ecoResProduct_ds   =          sender.dataSource(formDataSourceStr(EcoResAttributeValue, EcoResProductAttributeValue));
      EcoResProductAttributeValue      ecoResAttributeValue = ecoResProduct_ds.cursor();
<YOUR CODE>
}   

3.  Post-event hander of Form init or any other standard method method
[[PostHandlerFor(formStr(Ledger), formMethodStr(Ledger, init))]
    public static void Ledger_Post_init(XppPrePostArgs _args)
    {
        #ISOCountryRegionCodes
        FormRun form = _args.getThis();
        FormDesign design = form.design();
        FormControl revaluationAccount = design.controlName(formControlStr(Ledger, revaluationAccount));
        FormControl currencyRevaluation = design.controlName(formControlStr(Ledger, currencyRevaluation));

<your code>
}

4. Form control event hander:
[FormControlEventHandler(formControlStr(LogisticsPostalAddress, Roles), FormControlEventType::Modified)]
    public static void Roles_OnModified(FormControl sender, FormControlEventArgs e)
    {
        FormRun element = sender.formRun();
        FormControl purposeCtrl   = element.design().controlName(formControlStr(LogisticsPostalAddress, Roles));
       
        FormDataSource logisticsLocation_DS = element.dataSource(formDataSourceStr(LogisticsPostalAddress, LogisticsLocation));
       <business logic>
    }


Cheers,

Harry
Follow us on Facebook to keep in rhythm with us. @Facebook
Viewing all 341 articles
Browse latest View live