Query CRM from The Portal Connector (TPC) through Saved Queries

Within The Portal Connector we can make use of Saved Queries to define Fetch XML Query.

Once defined we get a REST based URL which can be used from our client side script.

Login to the Portal and go to Saved Queries

Click on Create a Saved Query

Click on Build and create a Fetch XML Query

The fetch xml builder

We can see the parameter added to the query string.

To consume it we can make use of JavaScript widget

Click on Edit and define the JavaScript inside it to call the function

The JavaScript code.


setTimeout(function(){

// get the logged in user's email i.e. contact in CRM

var userEmail=tpc.identity.userEmail;

var resp = $.ajax({
url: "http://abc.crmportalconnector.com/SavedQueryService/Execute/loyaltypointsavedquery/" + userEmail,
async: false,
dataType: "JSON",
}).responseJSON;
if(resp != null && resp.data != null)
{
var lp = resp.data[0].Attributes.new_loyaltypoint;
document.getElementById("lp").innerHTML = lp;
}
}, 1500);

Hope it helps..


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s