Saturday, 23 September 2017

Remove Forums link from CRM Portal Main Menu for unauthenticated users

Usually, we can manage hide/show of web links using web page access control rules in CRM Portals. But there are few links available on the portal that you cannot hide/show using access rules due to its own limitation. Forum link is one of them.

Below is the code that you need to add in Header Web Template in order to hide/show Forums web link for anonymous users in CRM Portal.

Paste the code in below-mentioned location in Header Web Template:



<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
var loggedInUserRole = '{{ user.roles }}';
if (loggedInUserRole.indexOf("Administrator") >= 0)
{
 $('a:contains("Forums")').parent().next().show();
 $('a:contains("Forums")').show();
}
else
{
 $('a:contains("Forums")').parent().next().hide();
 $('a:contains("Forums")').hide();
}
</script>

Anonymous User :


Administrator User :







Sunday, 3 September 2017

Dynamics CRM and Facebook Integration using Azure Logic Apps



According to survey, Facebook has nearly as many users as the entire population of China, the most populous country on Earth. That means it is likely that the vast majority of your potential customers and current clients have a Facebook account. Since Facebook collects an enormous amount of personal data, it is the ideal platform to learn more about your target group and reach its members, either for free or with effective campaigns.

As we all known about this fact, “The whole world is moving online and into social settings 
and Social media lets you engage your customers directly. If you have concerns about something, you can ask questions and receive responses quickly. If customers have questions or complaints, they can interact directly with a member of your team who should respond sympathetically to their concerns and try to resolve the issue.

Note - If you have not gone through my Logic Apps Overview Post. Recommend you to go through that first to more clarity about the terminology being used in this post. 

Today in this article, we will learn step by step -


How Facebook can be integrated with Dynamics CRM using Azure Logic Apps.

Requirement - Get Facebook notification in Dynamics CRM.

In this Example - We will use two Connectors - Facebook and Dynamics CRM

And one Trigger - When any new post on my Facebook timeline


Prerequisites :


You must be having below stuff ready before going to integrate Facebook to Dynamics CRM


  1. Azure Subscription (if not, get a free 1 month subscription from here)
  2. Dynamic CRM Organisation instance (if not, get a free 1 month trial from here)
  3. Facebook Account (if not, create your Facebook account from here 😀)

Step 1 : Sign in to the Azure portal and Search for Logic Apps.




Step 2 : Create a new Logic App.

Click On Add + to start creating new Logic app.

Name your logic app and select your Azure subscription. Now create or select an Azure resource group, which helps you organize and manage related Azure resources. Finally, select the data center location for hosting your logic app. When you're ready, choose Pin to dashboard and then Create.



Step 3 : Open Logic App Designer to design your first Logic App.


When you open your logic app for the first time, the Logic App Designer shows templates that you can use to get started. For now, choose Blank Logic App so you can build your logic app from scratch.
The Logic App Designer opens and shows available services and triggers that you can use in your logic app.





















Step 4 : Once you click on Blank Logic App, you will be having list of Logic Apps Connectors.
Search for Facebook Connectors by typing - Facebook in search box.


Step 5 : Select Facebook - When there is a new post on my timeline.

Here, Facebook Post is Trigger to run logic app


Step 6 : Set Interval - How often you want to check for Facebook notifications.


Step 7 : Once done, Click on Next Step



Step 8 : Add an Action - When there is a new Facebook post on my timeline.




Step 9 : Now search for another connector - Dynamics 365 and select Dynamics 365 - Create a new record


Step 10 : Select Organization Name, and select Task Entity in second dropdown.




Step 11 : Add below description in Subject field of Task Entity



Step 12 : Click Done. You will be able to see below design in designer.




OK Cool we are done witLogic Apps creation.  Its time to test what we have designed.

For testing, I have just posted one Post on my timeline.



As soon as I get a new Facebook post on my timeline, CRM should create a new Task record as per Logic App flow as below:

Hurrayyy!!! It worked...


Please feel free to share our feedback. Happy Integrating 👍

Sunday, 27 August 2017

Overview of Microsoft Azure Logic Apps



What is Logic Apps ?



  • Logic App service is a Code-less integration service for communicating with different services or platforms. With Visual business flows, B2B integration and developer friendliness, Microsoft makes themselves a strong contender in the cloud computing. Its high-time for all integration specialist to get acquainted to cloud technologies.
  • Logic Apps allow developers to design workflows that articulate intent via a trigger and series of steps, each invoking an App Service API app whilst securely taking care of authentication and best practices like durable execution.
  • Microsoft are investing strongly in this technology, introducing many new connectors in line with the demands of the integration requirements of enterprises. Azure LogicApps and ‘Functions’ are the backbone of serverless architecture in Azure. They both allow developers to quickly create and deploy code to the cloud that needs to be scalable, lightweight and fast. As the name implies, there are no infrastructure requirements; at least, no infrastructure that the consumers of serverless architecture should be concerned with, because it’s a fully managed service.
  • Logic apps are not only about integration and orchestration, but also about connectivity to other services. These services can be Azure based, SAP applications or 3rd party solutions such as OneDrive and DropBox: They can even be custom-built applications running on-premises, such as a web API.



Logic Apps Components



Connectors

The most basic element in any Logic App is the connector. Connectors are code elements bundled together to allow connectivity to a service. Each connector defines its own API and requires some information to be configured in order to connect to the corresponding service.
For Example : If we wants to make connection between Facebook and Dynamics 365, then Facebook and Dynamics 365 will be two Connectors of Logic Apps.

Triggers

Triggers are the events (CRUD) on which your Logic App will perform actions. They are used in conjunction to connectors to initiate the Logic App workflow. Each connector provides its own trigger definition.
For Example: Let say we want to Create a Task in Dynamics CRM, as soon as you get a new post on your Facebook Timeline. In this example, New Post on your Facebook Timeline is a Trigger point of Logic Apps.

Conditions

These are optional and can be used to inject some logic into the workflow. In some cases, the Logic App may be concerned with direct input and output.
For Example: If you want to create Task in CRM only when you have been notified on Facebook from a specific Users on your timeline. Otherwise create no task in CRM.

Actions

Every step in a Logic App definition is an action. This includes triggers, control flow steps like conditions, scopes, for-each loops, do-until loops, calls to connectors and calls to native actions. An action is what developers choose to do with the input that is received from a connector. 
For Example: Let say we want to Create a Task in Dynamics CRM, as soon as you get a new notification on Facebook. In this example, Create Task record in CRM is an Action of Logic Apps.



Logic Apps Pricing



Logic apps have no upfront setup costs. They also have no ongoing costs or infrastructure costs. The pricing works on the basis of consumption. This means that only you are only charged for executed actions.






















Logic Apps Deployment



Logic Apps are extremely lightweight and it is very easy to deploy. Visual Studio Team Services (VSTS) has built-in tasks for deploying Logic Apps. Alternatively, developers can create a custom deployment task for CI/CD using their favorite tools and either Azure PowerShell or the Azure CLI.



Conclusion



Logic Apps is a simple yet extremely powerful service that allows developers and enterprises to create cloud-based integrations and workflows with off-the-self, ready-made components. Instead of trying to work out which libraries, API and frameworks to use, the focus is placed on achieving as much as possible with as little effort as possible. Logic Apps are easy to develop and deploy. They come with a great DevOps story that can take the implementation from development to production in a few simple, reproducible steps with the power of ARM templates. New connectors are added daily, and the service is growing fast to accommodate a wide range of enterprise integration requirements.




My next post will be on How to connect Facebook with Dynamics 365 using Logic Apps.

Happy Integrating 👍

Sunday, 20 August 2017

Hyperlink on Lookup Values in CRM Portal




Hello Friends,

From last couple of days, I came across so many forums and communities and found so many folks are looking for a way to open lookup selected values in Portal so that users can see easily the details of lookup selected values.

Extending CRM lookup functionality to ADX portal gives users an rich experience in terms of user interface/functionality. However not all fields behave same in Dynamics CRM and ADX portal, look-up control being one such example. When viewed on ADX Portal form, look-up doesn't allow users to open up a new window giving details about the selected lookup value like CRM.

Today In this article I am going to share the code through which we can open the lookup selected value in portal.


Step 1 - Download the JS file from this link.

Step 2 - Create a Web File record (Portals > Web Files) with below details. And attach JS file (downloaded in Step 1) in Notes.




Step 3 - Create Entity Form in Edit Mode to view the lookup value. See below link to create Entity Form in Edit mode.

https://community.adxstudio.com/products/adxstudio-portals/documentation/configuration-guide/entity-form/


Step 4 - Use below code on Webpage Custom JavaScript section to Open Lookup Selected Values.


$(document).ready(function () {

//Parameter Description:

//Parameter 1   -   Lookup Html input element which store lookup text (can get it by doing F12)
//Parameter 2   -   Lookup Html input element which store lookup guid (can get it by doing F12)
//Parameter 3   -   Partial Name of webpage which is associated with Entity Form (Created in Step 3 Edit Mode)
//Parameter 4   -   location where you want to open new window to view lookup record (_self/_blank)


















 $.getScript('~/openlookuprecord', function () {

 openLookupRecord("case_name","case","Edit-Entity-Form-Webpage","_blank");
     
});

});





Step 5 - Open the webpage On Portal. As soon as you will select the lookup value, you will get Hyperlink over the value. Now when you click on Lookup value you will be redirected to Details Page.













Best part of this code is, its totally configurable. After attaching the JS file in Web File record, you just need to call openLookupRecord function.

Please feel free to get in touch in case of any query. Cheers 😃

Sunday, 30 July 2017

Field Validations - Adxstudio and CRM Portal


Hello Everyone, As we all know that XRM Model is not supported on Adx and CRM Portal. Therefore we cannot use CRM Forms scripts and Business Rules to perform Client side validation on Portal Entity Forms.

Though we have Entity Form Metadata in Adxstudio and CRM Portal to perform lot of validations but that is also not work for few of cases.

Today in this article I am going to share some Tips and Tricks to play with Custom JavaScript to perform various client side validations on Adxstudio and CRM Portal.


Hide/Show Fields on Entity Forms :


Below are the syntax that you can use to hide/show the entity forms fields (Text, Lookup, Option Set, Date Field etc)

$(document).ready(function(){

// To Hide
$("#fieldlabelId").hide();
$("#fieldvalueId").hide();

// To Show
$("#fieldlabelId").show();
$("#fieldvalueId").show();

});

or

$(document).ready(function(){

// To Hide
$('#fieldlabelId').parent().parent().hide();

// To Show
$('#fieldlabelId').parent().parent().show();

});

Note : Rather Hide/Show Text Field Label and Textbox separately you can use above syntax to Hide/Show the whole Text field control (Label + Textbox)

Enable/Disable Fields on Entity Forms :


Text Field -


$(document).ready(function(){

// Disable the field
$("#textboxId").prop('disabled',true);

// Enable the field
$("#textboxId").prop('disabled',false);

});

Lookup Field -


$(document).ready(function(){

disableLookup('regardingobjectid_name', 'regardingobjectid_entityname');

});

function disableLookup(LookupNameID, LookupEntityNameID) {
    
    var L_EN_ID = '#' + LookupEntityNameID;
    var L_N_ID = '#' + LookupNameID;
    $(L_EN_ID).next().remove();
    $(L_N_ID).css('width', '329px');
}


Optionset Field -


$('#sw_premisetype').prop("disabled", true);



Hide/Show Section on Entity Forms :


Hide Section -


$('table[data-name="section_name"]').closest('fieldset').hide();

Show Section -


$('table[data-name="section_name"]').closest('fieldset').show();


Disable/Enable Section on Entity Forms :


Disable Field -


$('table[data-name="sec_AccountDetails2"]').closest('fieldset').find("input,button,textarea,select").attr("readonly", true);


Enable Field -


$('table[data-name="sec_AccountDetails2"]').closest('fieldset').find("input,button,textarea,select").attr("readonly", false);

Note : If you get any requirement to make the portal section disables, Rather making it Disable, you must always make it Read-only, because disable section fields values does not store in CRM.
Above syntax is to make the section Read-only instead of Disabled.


Hide/Show Tab on Entity Forms :


Hide Tab-


var tab = $('table[data-name="section_name"]').closest('.tab');
var label = tab.prev('.tab-title');
tab.hide();
label.hide();


Show Section -


var tab = $('table[data-name="section_name"]').closest('.tab');
var label = tab.prev('.tab-title');
tab.hide();
label.show();


Hide/Show Date-time Control on Entity Forms :


Right Click on Date Field Control Textbox and click on Inspect. Now copy the value of 'aria-describedby' attribute.

$('input[aria-describedby="<copied value of aria-describedby>"]').parent().parent().hide();

Above syntax use to Hide/Show Date-Time Textbox Control

Below syntax use to Hide/Show Date-Time Textbox Control

$(''datefield_label").hide();



Please feel free to get in touch with me if you want to get advice for some more validations. I'd love to hear from you.

Tuesday, 20 June 2017

Auto-Complete for Lookup Controls in CRM Portal

Yes, you heard it right and landed on right location.




This is something we wanted since long time in Adxstudio Portal and now in CRM Portal . the term ‘autocomplete’ might be a bit misleading since the field is not automatically completed but instead you can select the suggested item from the list.

Till now, neither in Adxstudio nor in CRM Portal has this feature which sometime leaves a bad impression because some users have commented that the user experience is not as intuitive as they would like.

User would expect to be able to type into the control to look up data, or at least be able to interact with the text element of the look-up control.

As per the Adxstudio Community, they would like to add this feature in future release, though they don't have a timeline for when they might do so.

This article has step by step guide to achieve autocomplete feature on Portal lookup controls :

Here we go...

You do not need to do anything, I have made set everything for you 👍

You just need to do some simple configuration to make it work.

Step 1: Download the JavaScript File from here

Step 2 : Create a Web File record (under Portal > Web Files) with below mentioned details.


Step 3 : Attach JavaScript file in 'Notes' that you have downloaded in Step 1.

















Step 4 : You are all set with the require configuration. Now to apply Lookup Search or Lookup Autocomplete feature you just need to go to Custom JavaScript section of either Webpage or Entity Form.

$(document).ready(function() {

//Parameter1 ------> Lookup Field's Entity Name

//Parameter2 ------> PrimaryField name of Lookup Field's Entity Name 

//Parameter3 ------> OData Feeds Entity Set Name (Entity List that you have been created for OData Feeds)

//Parameter4 ------>  'Field Name' that you want to search in Lookup Field.

//Parameter5 ------>  'Lookup Field Name Id' on which you are enabling Search feature.(<input id="lookupfieldname_name"></input>)

//Parameter6 ------>  'Lookup Field Id' on which you are enabling Search feature. (<input id="lookupfieldname"></input>)

//Parameter7 ------>  'Lookup Field Entity Name Id' on which you are enabling Search feature. (<input id="lookupfieldname_entityname"></input>)

Note : Those who are confused what does Parameter 5,6,7 actually means can look the below snapshot for more information. Every Lookup on Portal comes with three IDs highlighted with yellow.



//Parameter8 ------>  'Guid' of Portal Logged In User.


//Parameter9 ------> 'Field Name' of Lookup Field's Entity in which you are storing Contact Name.

  var loggedinUser = '{{ user.Id }}';

  var loggedinuserAccount = '{{ user.parentcustomerid }}';

   $.getScript('~/content/LookupSearchContol', function () {
   
 // If you don't want to incorporate logged In User security on lookup autocomplete, just pass the last two parameters value as null

ApplyLookupSearch("contact", "contactid", "contacts", "fullname", "looupfield_name", "lookupfield", "lookupfield_entityname",null,null);


// If you want to incorporate logged In User security on lookup autocomplete, just pass the last two parameters value as below  

or

// Lookup Autocomplete items will be Filtered based on Logged In User

ApplyLookupSearch("incident", "incidentid", "cases", "ticketnumber", "looupfield_name", "looupfield", "lookupfield_entityname",loggedinUser,"primarycontactid");


// If you want to incorporate logged In User Account security on lookup autocomplete, just pass the last two parameters value as below  

or

// Lookup Autocomplete items will be Filtered based on Logged In User Account

ApplyLookupSearch("incident", "incidentid", "cases", "ticketnumber", "looupfield_name", "looupfield", "lookupfield_entityname",loggedinuserAccount,"customerid");

   });
   
});


Step 5 : Once you are done with all the above mentioned configuration for 'Lookup Autocomplete' feature, You just need to log Into your Portal and go to that Lookup in which you have enabled searching option.

Type the text and press 'Tab' in the keyboard, you will find list of all related items/records in the list matched to your types text same like CRM.


For Example :

Suppose you have 'State' or 'City' Lookup field on Portal Entity Form and you want to incorporate Lookup Autocomplete then you have to call function as below :

ApplyLookupSearch("stateentityname", "stateentityprimaryfieldname", "states", "name", "looupfield_name", "looupfield", "lookupfield_entityname",null,null);

I kept last two parameters null, because I don't want to apply logged In user security here.

But, suppose if I have 'Case' lookup field on Portal Entity Form and you want to incorporate Lookup Autocomplete then you have to call function as below :

ApplyLookupSearch("incident", "incidentid", "cases", "ticketnumber", "looupfield_name", "looupfield", "lookupfield_entityname",loggedinUser,"primarycontactid");

In this case, it's is mandatory to apply logged In user security on lookup autocomplete, as we would like to show only logged In user Cases instead of all User Cases in autocomplete list.

Same if you want to apply security based on Logged In User Account basis then apply Logged In user Account Id and Account Field name (in last two parameters) in which you are storing Account details.


Please feel free to get in touch and share your inputs with me. Happy CRMing...😊
Blogger Widgets