Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

How to stop saving a record while using o data query in javascript

$
0
0

Hi All,

I am having a problem using odata Query.

I am having a Custom entity with name "abc". Here i have two fields named CustomerId and Admission date. CustomerId is a lookup field from some other entity. Now in the "abc" entity i would like to add a new record, but before saving that record i would like to check whether any other record present with same combination of ClientId and Admission date. Here i used odata query for condition and SDK.Rest service for retrieving records. Below is the code:

var FieldObject = Xrm.Page.getAttribute("new_clientid");
    var FieldValue = FieldObject.getValue();
    var recordId = FieldValue[0].id;
    if (recordId != null) {
        var options = "select=new_name&$filter=new_ClientId/Id eq guid'" + recordId + "' and new_Admissiondate eq datetime'"+Admissiondate+''";
        SDK.REST.retrieveMultipleRecords('new_admission', options, successCallbackResults, function (error) { alert(error.message); }, function () { }, true)

I am implementing this functionality on ONSave event. But the problem is i am unable to prevent the saving of record even if there is record present in the "abc". What functionality do i need to implement in successCallbackresults.

Any help is Appreciable

 



Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>