Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Using Web API Function in CRM 2016 - Part Two
WhatsApp
Mahender Pal
8y
10.4k
0
0
100
Article
In our
last article
we discussed standard functions, today we are going to discuss Query Function. These functions are basically conditional operators, so there is conditional operator corresponding to every query function. We can get a complete list of query function references from
here
. We can use these functions similar to standard function, but we just need to make sure to include full name of the function while using it.
The following is the sample code for using query function:
function
GetNextMonthEvents() {
var
serverURL = Xrm.Page.context.getClientUrl();
var
req =
new
XMLHttpRequest();
req.open(
"GET"
, serverURL +
"/api/data/v8.0/him_events?$select=him_eventname&$filter=Microsoft.Dynamics.CRM.NextMonth(PropertyName='him_eventstartdate')"
,
true
);
req.setRequestHeader(
"Accept"
,
"application/json"
);
req.setRequestHeader(
"Content-Type"
,
"application/json; charset=utf-8"
);
req.setRequestHeader(
"OData-MaxVersion"
,
"4.0"
);
req.setRequestHeader(
"OData-Version"
,
"4.0"
);
req.onreadystatechange =
function
() {
if
(
this
.readyState == 4
/* complete */
) {
req.onreadystatechange =
null
;
if
(
this
.status == 200) {
var
data = JSON.parse(
this
.response);
alert(data.value.length);
}
else
{
var
error = JSON.parse(
this
.response).error;
alert(error.message);
}
}
};
req.send();
}
In above sample code we are using
NextMonth
query function. This query function takes one parameter, which is the name of the attribute that we want to validate. We are using this function to get a list of event sthat are happening next month. So it will query our custom event entity and will display the number of events which are scheduled next month. We can create script web resources and use above code there. If you are new to web resources refer to my earlier posts for how to create web resources and use them.
Stay tuned for more
Dynamics CRM
updates!!
Read more articles on
Dynamics CRM
:
Dynamic CRM Operations With Your ASP.NET Application
How to Change Icon of Custom Case Origin in Dynamics CRM 2015
Dynamics CRM
eb AP
eb API Functions
RM 2016
Up Next
Ebook Download
View all
Printing in C# Made Easy
Read by 22.3k people
Download Now!
Learn
View all
HIMBAP
We are expert in Microsoft Power Platform.
Membership not found