Step 1: Enable the
portal entity list(Contact,Account,etc)
Go to Portal > Entity List. Create
a new Entity List for Case Entity.
Step2: Enable
Odata feed with entity type and views also in entity list
Step3: Now, To retrieve the data, Hit the URL in browser.
URL : Portal_URL/_odata
URL : Portal_URL/_odata/Entity_Set_Name
: To retrieve the
data
Here we can see the
<atom:title type=”text”>Cases</atom:title>
Step4: Upload
your JavaScript in your respective “entity form”.
Below script :
if
(window.jQuery) {
(function ($) {
$(document).ready(function () {
if (typeof (Page_Validators) ==
'undefined') return;
// Create new validator
var newValidator =
document.createElement('span');
newValidator.style.display =
"none";
newValidator.id = "titleValidator";
newValidator.controltovalidate =
"title";
newValidator.errormessage =
"<a href='#title_label'>This Case has been already
generated.</a>";
newValidator.validationGroup =
""; // Set this if you have set ValidationGroup on the form
newValidator.initialvalue =
"";
newValidator.evaluationfunction =
function () {
var count = GetCase();
if (count > 0 )
return false; // Return false mean apply validation.
else
return true; // Return true mean successful.
};
// Add the new validator to the page
validators array:
Page_Validators.push(newValidator);
// Wire-up the click event handler of
the validation summary link
$("a[href='#title_label']").on("click", function ()
{ scrollToAndFocus('title_label','title'); });
});
}(window.jQuery));
}
function
GetCase(){
var count = 0;
var title=$("#title").val();
$.ajax({
type: "GET",
contentType: "application/json;
charset=utf-8",
datatype: "json",
url: "~/_odata/Cases?$filter=title eq
'"+title+"'",
beforeSend: function(XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept",
"application/json");
},
async: false,
success: function(data, textStatus, xhr) {
count = data.value.length;
},
error: function(xhr, textStatus,
errorThrown) {
Xrm.Utility.alertDialog(textStatus +
" " + errorThrown);
}
});
return
count;
}
Step5: If
duplicate case is created then it will show you like “This
Case has been already generated.”
Please refer to below screenshot.










