Tuesday, 12 May 2020

Tutorial: Customize and Deploy Dynamics 365 Marketing Event Management or Other Portal


Hi everyone,

I would like to share how to customize and deploy portal code to your Dynamics 365 Portal.
Before that, make sure you have read my other post regarding to what the pre-requisites are and how to code & test plus deploy locally.

This is to ensure you have done every step, including downloading sample website to customize the source code and you have done the required steps without missing anything.

Next is how do you customize it?

First, you just need to try if you are able to modify small changes and then deploy it to your Dynamics Marketing Portal (or any other portal I guess).
I am using Marketing – Event Management Portal because I am working on some requirements and I have searched in the internet, there is no detailed steps at the moment, so I tried and encountered errors and tried again until I managed to find the answer and want to share it.

Here is the portal before I customize
 

(*Actually I have customized some – the Aileen Test is the additional I added during testing 😊 , but let’s just use this as our original state*)

So, now let’s say you want to add something or change color, you can go back to your code (again, I assume you know already how to access your code – that’s why my above link is useful for starter).

YES!! You don’t need to run Visual Studio App then open the project, you can just using PowerShell

I am using very simple PowerShell:
 
It then will open Visual Studio Code

Now let’s follow the steps to customize it
Let’s see you want to modify the Main Page like what I did for Aileen Test, you need to understand where is it being located in your Portal and the Source Code.
Do you know where is it??

Here is the default Marketing – Event Management Portal



So, the first page is the All Events, I have been searching in any web files and any web/page template, code snippets in the Dynamics 365 instance but I got nothing.
I searched in the internet, I could not find it, and it is actually the way Angular works (P.S. I did not have much experience using Angular except for this one and PCF 😊) is by compiling everything and put it into main.js only.

Okay, since there is no much information, I tried to find it one by one and I tried to find “Available Events” keyword.

Have you found where it is??


Yes, it is behind the code!!

I found it in the home.component.html, which is located under src->app->components->home



However, you will not find it in the Home HTML in your Dynamics 365 instance just like old days of Portal. Not here, not there..



Not even here..






So, let’s just try and I will let you know where it is stored.

 Now, you want to change the color and add some words:



After that, you just want to deploy it!

To deploy it, you need to go to the DeployToDynamics365Instance.ps1 – it is located under Scripts folder

Then you need to change the Connection string or you can use InteractiveMode by uncomment it and comment the next return.

Remember in Powershell script # is comment not // or <!—or --

 Then after that you just need to Run/execute the script

I am using this button to run:


Wait.. and wait


then refresh your portal after you see this:



Refresh and here is what you will see (you may need to wait a while and keep hitting Ctrl+F5)



Before
After


Now you know how to customize it and deploy it LIVE to your Dynamics Portal.

But, are you wondering “Where is my customization stored actually”?

Actually, it is inside the main.es file (Web files)





Hope this helps!

Thank you and stay safe & healthy everyone!

Sunday, 10 May 2020

workflow With Id = 31313393-0368-47ad-b937-58626a150bb4 Does Not Exist CRM Online error when Activate Routing Rule and 'Workflow' entity doesn't contain attribute with Name = 'Workflowid'. error

Hi all,
Just a quick share here:
if you encounter this error:
<Message>workflow With Id = 31313393-0368-47ad-b937-58626a150bb4 Does Not Exist</Message>
When you try to activate a Routing Rule Set.
It can be caused by missing workflow, because once you create a Routing Rule Set, it will create a workflow with the same name as well.
So, ideally, it will have 2 components with the same name here: (as once you add Existing Routing Rule set in the solution, by default it will add , not only 1)
image
In my environment, somehow, it only has 1, so there is no Process at all, only Routing Rule set is there.
image
It makes the error happens during export solution or even just try to activate the Routing Rule
So, the solution here is to create a solution that contains workflow with that ID, for this you need to tweak your solution and customization.xml files.
In your other environment, please create a solution with Routing Rule Set, please name the same as your troubled Routing Rule Set.
And do the same thing, the condition, the workflow, everything must same.
Then, make sure there are 2 items in the solution, export it.
And then modify the XML and also the workflow folder.
Then, rename everyID of the related workflow, either inside the workflow node or routing rules node:
image
image
*Inside the workflows folder
image
Then import it, if you are successfully import it, CRM will re-create the workflow with the same ID.
Fix this will fix your Export Solution problem as well.
Hope this helps.
Thank you.

Tutorial: How to Build, Deploy, and Test Locally Dynamics 365 Portal or Dynamics Marketing Event Portal and Connect it to your Dynamics 365 instance LIVE!

Even wondering how to customize the Dynamics Marketing Portal or any other Dynamics 365 Portal?
Keep deploying and retesting is not efficient and productive, the best is if you manage to start develop and deploy it locally first. This what I want to share here.

Finally, after few hours have been trying, I managed to test locally the Portal that I want to customize.
There are many documents outside there, however let me just share to you steps that I exactly did.

*I assume you already have the Portal, otherwise please configure the Portal first.

Steps:
1. Please read carefully these published documents to understand the concept
https://docs.microsoft.com/en-us/dynamics365/marketing/portal-optional
https://docs.microsoft.com/en-us/dynamics365/marketing/developer/event-management-web-application
https://docs.microsoft.com/en-us/dynamics365/marketing/developer/event-management-web-application
https://docs.microsoft.com/en-us/dynamics365/marketing/developer/manually-overwriting-sample-website

2. Please fulfill the pre-requisites
https://docs.microsoft.com/en-us/dynamics365/marketing/developer/event-management-web-application

First, download your source code based on the version you want
https://docs.microsoft.com/en-us/dynamics365/marketing/developer/event-management-web-application#download-sample-event-website

Second, Install Node.js version 10.x or higher.

3. Then, you should follow the steps in the document

Your final expectation should be you have the folder and  the package.json folder is the path you need to run all your ps scripts




4. After that, you can open this doc
https://docs.microsoft.com/en-us/dynamics365/marketing/developer/portal-hosted#environment-configuration

5. You can then open the project using Visual Studio for your convenience only by executing "code" command, see below

*I feel this is important otherwise you do not have one single UI to manage your files










6. Okay, then go back to this link and follow the steps
https://docs.microsoft.com/en-us/dynamics365/marketing/developer/portal-hosted#environment-configuration

The tricky part that I was stuck is you may be giving wrong URL in the environment.ts and ended up having unknown error
To avoid that, let me share my configuration














anyway, by right apiEndPoint is the one variable you should change

The value you should get from the Website Binding (see my left navigation) and you need to put https:// and ended with another slash like what it says: "You need to add a trailing slash at the end of the URL."
























Is that all? Nope!

7. You need to go tho this link:
https://docs.microsoft.com/en-us/dynamics365/marketing/developer/portal-hosted#local-development
Then, you can run all the commands such as npm install

If you are stuck here: ng build --prod --output-hashing none

It is okay, you can just change it to just ng build
















Is that all? I believe you will still hit error even after you run ng serve succesfully.

Hit this URL: http://localhost:4200/home

*I'll tell you about this URL, anyway this is the default port that I have (4200)


**Note: if you find another error, it can be you passed wrong parameter in the environment.ts


8. There is one thing you should not miss it to add few more settings, therefore, before that you can add this setting which you can view the instruction from:

https://docs.microsoft.com/en-us/dynamics365/marketing/developer/portal-hosted#configuring-cross-origin-resource-sharing-cors

Yes, you need to add the CORS setting

How do I get the http://localhost:4200 ??

Well, back to your Command after you run ng serve then you will find your answer



9.  Now, hit the URL again and you will see your live data!

Yesss now you can see it already.
*If it does not work? You may need to Restart your portal


































Next is how do you deploy? You can deploy it manually or you can use the script, the script is in the folder already.
Script name: DeployToDynamics365Instance.ps1
Location: ..\EventWebsite\release\Scripts 
(*your location may be different, but it is inside the Scripts)

Don't forget to change the connection string in the ps script or you can enable interactive mode
Find this keyword, you can comment or uncomment this part

 #return Get-CrmConnection -InteractiveMode

I will cover how to customize and deploy it, this is something I was struggling previously to understand how the structure works.

Hope it helps!



Hi everyone,

Have you encountered "Method not found" error whether when you trying to connect to Plugin Registration Tool, XRM Toolbox, or just to run interactive mode of CRM Connection Control using XRMTooling Connector? This happened to me recently when I tried to connect to CRM using PowerShell to pop up the Connection Control interactive mode. I was trying to deploy my customization to the Dynamics Portal.

Here is the typical error message.
Note: the Method can be vary.

Source : Microsoft.Xrm.Tooling.CrmConnectControl
Method : QueryOnlineServerList
Date : 5/10/2020
Time : 3:34:45 PM
Error : Method not found: 'Microsoft.Xrm.Tooling.Connector.Model.CrmOnlineDiscoveryServer Microsoft.Xrm.Tooling.Connector.Utilities.DeterminDiscoveryDataFromOrgDetail(System.Uri, Boolean ByRef)'.
Stack Trace : at Microsoft.Xrm.Tooling.CrmConnectControl.CrmConnectionManager.QueryOnlineServerList(ObservableCollection`1 svrs, OrganizationDetailCollection col, ClientCredentials liveCreds, Uri trimToDiscoveryUri, Uri globalDiscoUriToUse)
   at Microsoft.Xrm.Tooling.CrmConnectControl.CrmConnectionManager.FindCrmOnlineDiscoveryServer(ClientCredentials liveCreds)
   at Microsoft.Xrm.Tooling.CrmConnectControl.CrmConnectionManager.ValidateServerConnection(CrmOrgByServer selectedOrg)
======================================================================================================================

I was struggling to find out why and keep copying the file in the folder with the latest SDK, however it did not work.

Apparently, the root cause is  the compatibility of the Microsoft.Xrm.Tooling SDK with the tool you are running now or with the Microsoft.Xrm.Sdk.dll.

In my case, no matter how many times I tried to copy and replace, download latest SDK, it did not work.
It is because I have the problematic dll installed in the GAC

Solution:
1. Go to GAC Folder
C:\Windows\Microsoft.NET\assembly\GAC_MSIL

2. Find the dll folder that caused your error, in my case it is Microsoft.Xrm.Tooling

3. Then backup and delete the folder

I guess there is another way to uninstall this GAC dll, but due to limited time and this is just my personal PC, I was choosing the quickest method that is deleting the folder.
After that, I have no issue to run it again.
Be it Plugin Registration Tool, the wonderful XRMToolbox or any other apps, if you encountered the same issue, you can just perform my above solution.
Remember, use it on your own risk.

Thank you and have a great day!

Duplicate Detection Error Message: You can include only 450 characters in the matchcode. Either change or delete rule conditions to reduce the number of characters included, and then try again.


image
---------------------------
Message from webpage
---------------------------
You can include only 450 characters in the matchcode. Either change or delete rule conditions to reduce the number of characters included, and then try again.
---------------------------
OK  
---------------------------

So, the solution is to check the field length:
image

After reduce it to 450, then you can only publish the duplicate detection rule

image

Wednesday, 27 February 2019

Alert and Confirm syntax will not work for Dynamics 365 App For Outlook

Recently, I just helped customer to upgrade their system to 9.1.x.x
We encountered many issues. However, the issue that I want to bring up now is issue regarding to the App for Outlook

We found that there is custom ribbon that calls Custom Javascript and it does nothing, no error, nothing is so-called exception occurred because I did debugging and did place the try catch block.
Unlike using Web, the debugging in Outlook is not so easy.
After I did debugging with try catch, I found out that the script is actually running well and has no error.

So, the problem is: the script that is executed is pretty simple just do some validation and show alert when does not fulfill, then throw a confirmation dialog then save the form.
Yes, the script is sucessfully executed from start to the end.

Then, why the ribbon function is not running?



It is because the alert and confirm scripts are still using old ways:

alert("Please complete all mandatory fields before submitting the form")
if (!confirm("Are you sure that you want to submit this form??")) {
            return;


So, there is no error it is just not 'supported' and not 'translated' well in the App for Outlook.
yes, it does working in Web, but not in App for Outlook.

So, after I changed it to

 Xrm.Utility.alertDialog("Please complete all mandatory fields before submitting the form");
or
    var alertStrings = { confirmButtonLabel: "OK", text: "Please complete all mandatory fields before submitting the form" };
    var alertOptions = { height: 100, width: 500 };
    Xrm.Navigation.openAlertDialog(alertStrings, alertOptions);

and

if (!Xrm.Utility.confirmDialog("Are you sure that you want to submit this form??")) {
            return;
        }

It is working perfectly!
Example:








**The first one is still supported and it is intended for simple alert.
Xrm.Utility namespace may be obsolete for the Alert and Confirm Dialog, so as per MSDN recommendation, we need to change it :
https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-navigation/openalertdialog

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-navigation/openconfirmdialog

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/xrm-utility

Hope it helps!

Thanks




Wednesday, 23 January 2019

Be careful when you import managed solution and you modify that component

Hi all,

Just a short blog as per current experience.
I know it has been years I never write any post.

So, my current post is just want to explain that should you imported solution as Managed and then something requires you to update.
Does not matter it is just a display name for name, is searchable Advanced Find for a field, a Report Category for a Report, Web Resources modification directly from the Production with Managed solutions.

Please be noted that you are doing wrong thing and there is no way back for CRM Online other than raising ticket which can be rejected as it will make that component becomes 'Unmanaged' and is part of Active or you call it Default Solution.

Well, you can see it is still "Managed" in your Managed solution, but it is actually a Default Solution
It means, your component CANNOT Be DELETED anymore using Holding nor Solution Upgrade or manually you CANNOT Delete. It will remain there.

So, if you have fields you want to delete, dont hide it.
If you have report you want to hide dont hide it.
Dont do that directly in your Managed Solution environment.
Do it in the UNMANAGED Solution and you can use SOLUTION UPGRADE method to delete that component like people posted before.

This what happen the moment you changing something in your report:

The report you modified directly become "Unmanaged" and part of the "Default Solution" as the final layering. You WILL NOT be able to deploy the Managed solution again which has this component.
As there is conflict internally in the database.

So, dont do that.
Always stick in your Development for any modification.
If it is something like Report, sitemap that frequently changing and easy to maintain, it is still the best to keep it Unmanaged so you can modify and delete if you dont like it, all manually but possible.
Well, like entities, changing directly in PROD is not recommended.

Or, you can prevent the customizable


Hope this is useful.
Thanks