Thursday, August 23, 2018

d365FO - how to change model layer

In d365FO, once a model was already created, the layer is NOT able to changed. However there is a simple trick to do that. The following example shows how to change model layer from USR to ISV.

1. Stop AOS service in IIS
2. Edit C:\AOSService\PackagesLocalDirectory\yourModel\Descriptor\yourModel.xml

        from
<Layer>14</Layer>

        to
<Layer>8</Layer>

3. Edit the VS solution file, for example C:\users\aaa\yourModel\yourModel.sln

        Change below USR to ISV

        MinimumVisualStudioVersion = 10.0.40219.1
        Project("{FC65038C-1B2F-41E1-A629-BED71D161FFF}") = "yourModel (USR) [Funny company]", "yourModel\yourModel.rnrproj", "{3F0DF531-7E6A-47A7-8230-B22D299794C5}"
EndProject

4. Start AOS service in IIS

5. Launch VS and build the model again to verify the change.

That's all!




Ref:
Alex Kwitny's comment https://stackoverflow.com/questions/42513406/how-can-i-change-the-layer-from-usr-to-isv-in-dynamics-365-for-operation

Wednesday, August 22, 2018

d365FO | Idea to connect d365FO projects with source control (VSTS)

 For a simple scenario, a developer has only onebox (one AOS) and will develop many projects for a company. And need to plug all projects to source control.















The main reason for this topology is an AOS environment can be occupied by only one source control. (In this case, AOS environment means C:\AOSService\PackagesLocalDirectory) So you need 1 LCS project and 1 VSTS organization and 1 VSTS project.

In the VSTS project, you can create a couple of folders that correspond to 1 VS solution. Such idea would be able to handle whole AOS and all d365FO projects.

Until the next post!

d365FO - How to unbind or disconnect d365FO projects from source control (VSTS)

Sometimes, you probably need to re-organize the projects and source control. One of the task is to disconnect d365FO objects from source control.

(VSTS stands for Visual Studio Team Services)

Here, the steps.
1. Backup your files and metadata
2. Unbind
3. Remove mapping
4. Remove VSTS connection in VS
5. Remove Workspace in VS
6. Remove the VSTS project binding in LCS project
7. Remove a VSTS project in VSTS organizations
8. Remove a VSTS organization
9. Remove a LCS project


1. Backup your files and metadata
        a. d365FO projects and model - These can be backup by export axpp projects
        b. VS files and folder - Solution, project and related folders
        c. d365FO model metadata - For example, C:\AOSService\PackagesLocalDirectory\XXXmodel

2. Unbind
This is for unbind/disconnect the local artifacts from the source control (VSTS)











After finish this step, you should check the availability of the VS local files and folders.

3. Remove mapping

**You do this step if you don’t want to keep configuration between local machine and VSTS to re-bind it in the near future.

**Normally, make sure you finish unbind step before, unless the some of local files might be removed.













**Since step 4. It's optional. You probably do it all or just some steps on your need.

4. Remove VSTS connection in VS
5. Remove Workspace in VS























6. Remove the VSTS project binding in LCS project











7. Remove a VSTS project in VSTS organizations



















8. Remove a VSTS organization

















9. Remove a LCS project


















Until the next post! ;-)



Ref:
https://support.smartbear.com/testcomplete/docs/working-with/integration/scc/tfvc/common-tasks/unbinding.html



Monday, August 20, 2018

d365FO - how to copy elements from a model to another

One of requirement you probably come across is to copy/move objects across models. Here, a simple way I did.

Task - Copy and rename ABC- to XYZ- classes across the following environments. Server A (Model X) --> Server B (Model Y)

Solution
1) Make sure model, VS solution and VS project are already created for the new model Y.
2) Close and exit from Visual studio IDE.
3) Copy all ABC- classes to folder C:\AOSService\PackagesLocalDirectory\Y\Y\AxClass.
4) Rename all prefix of file name by Windows PowerShell.
            Dir | Rename-Item -NewName {$_.name -replace "ABC","XYZ"}
5) Use your text editor to rename "ABC" to "XYZ".
6) Repeat step 3-5, but on C:\AOSService\PackagesLocalDirectory\Y\XppMetadata\Y\AxClass
7) Find the source project file (RNRPROJ file), and then copy the following structure to the destination project file. And yes, again rename the prefix to XYZ.
    <Content Include="AxClass\ABCprocessClass">
      <SubType>Content</SubType>
      <Name>ABCprocessClass</Name>
      <Link>Classes\ABCprocessClass</Link>
    </Content>
8) Open Visual studio again. Verify the change by build the model.

Until the next post!


Ref:
https://community.dynamics.com/ax/f/33/t/193502
http://daxonline.org/1607-how-to-import-project-from-one-model-to-another-d365fo.html
https://www.windowscentral.com/how-rename-multiple-files-bulk-windows-10

Monday, August 13, 2018

X++ | d365FO | reflection - GetField not return a value

I found that method GetField not return a value as expected in some case, see below figure. The problem is on line 9, the variable 'field' get a null value return, instead of custConfirmJour.



























Solution
The reason is still unclear to me. But to solve it in very simple way, just declare all type of bindingFlags as follows.

using System.Reflection;

[ExtensionOf(classStr(SalesConfirmController))]
final class SalesConfirmController_XXX_Extension
{
    Common XXX_ABC()
    {
        //var bindFlags = BindingFlags::Instance | BindingFlags::NonPublic;
        var bindFlags = BindingFlags::Instance | 
BindingFlags::NonPublic |
                        BindingFlags::Static | 
                        BindingFlags::Public;
        var field = this.GetType().GetField("custConfirmJour", bindFlags);
        Common ret = field.GetValue(this);

        return ret;
    }

}

Until the next post!


References:
https://stackoverflow.com/questions/1040803/whats-wrong-with-this-reflection-code-getfields-is-returning-an-empty-array
https://msdn.microsoft.com/en-us/library/4ek9c21e(v=vs.110).aspx

d365FO - Table browser error - You are not authorized to login with your current credentials.

I found this problem in when trying open table browser inVisual studio for d365 FO (MS Dynamics 365 for Finance and Operations, Enterprise edition) VM on-premise. It looks simple but so far no rescue.




Only the interim solution to access directly on web browser like:

https://usnconeboxax1aos.cloud.onebox.dynamics.com/?mi=SysTableBrowser&cmp=DEMF&tablename=SalesParameters&limitednav=true



Will update again as soon as found the better solution. Have a nice day!


Ref: http://axhelper.com/?p=10842