///=================================================================================
// creation records using mscrm2016 application
// created by Ravi Jaala on august 5th 2016
//===============================================================
if (typeof (MscrmAplications) == "undefined") {
MscrmAplications = { _namespace: true };
}
MscrmAplications.Studentonload =
{
CreateRecord: function () {
debugger;
var student = {};
student.new_name = "DemoExample";// string
student.new_courseName = "MSCRMTechnologies";// string values
student.new_CourseDuration = { Value: 100000001 }; // optionset values
student.new_Gender = false;//Two OptionSetvalues
student.new_Fee = { Value: "60000" }; // currency field
var dt = new Date(2015, 9, 8);
student.new_startdate = dt; // date and time field
student.new_TotalSudents = 200;// whole numbers
student.new_Amount = "6.2";// floating point
student.new_Hieght = "9.9"; //decimal
student.new_Student = { Id: "F3397DD5-1458-E611-80F1-C4346BDD3121", LogicalName: "new_students", Name: "StudentC" };//lookupvalues
SDK.REST.createRecord(student, "new_course", MscrmAplications.Studentonload.sucessful, MscrmAplications.Studentonload.errormessage);
},
UpdateRecords: function () {
debugger;
if (Xrm.Page.data.entity.getId() != null) {
var RecordId = Xrm.Page.data.entity.getId()
if (Xrm.Page.getAttribute("new_demos").getValue() != null) {
var Opts = Xrm.Page.getAttribute("new_demos").getValue()
if (Opts == 100000000) {
var student = {};
student.new_name = "DemoExample";// string
student.new_courseName = "MSCRMTechnologies";// string values
student.new_CourseDuration = { Value: 100000002 }; // optionset values
student.new_Gender = false;//Two OptionSetvalues
student.new_Fee = { Value: "60000" }; // currency field
var dt = new Date(2015, 9, 8);
student.new_startdate = dt; // date and time field
student.new_TotalSudents = 900;// whole numbers
student.new_Amount = "1.1";// floating point
student.new_Hieght = "8.9"; //decimal
student.new_Student = { Id: "364010EF-1458-E611-80F1-C4346BDD3121", LogicalName: "new_students", Name: "StudentB" };//lookupvalues
SDK.REST.updateRecord(RecordId, student, "new_course", MscrmAplications.Studentonload.sucessful, MscrmAplications.Studentonload.errormessage);
}
else if (Opts == 100000002) {
debugger;
SDK.REST.deleteRecord(RecordId, "new_course", MscrmAplications.Studentonload.sucessful, MscrmAplications.Studentonload.errormessage)
}
else if (Opts == 100000003) {
debugger;
}
}
}
},
RetrievRecords: function () {
debugger;
if (Xrm.Page.data.entity.getId() != null) {
var RecordId = Xrm.Page.data.entity.getId()
if (Xrm.Page.getAttribute("new_course").getValue() != null) {
var lookup = Xrm.Page.getAttribute("new_course").getValue();
var Id = lookup[0].id;
SDK.REST.retrieveRecord(Id, "new_course", null, null, MscrmAplications.Studentonload.sucessfulrestrieve, MscrmAplications.Studentonload.errormessage)
}
}
},
sucessful: function () {
alert("sucessfuly excuted");
},
errormessage: function () {
alert("Error Occured here");
},
sucessfulrestrieve: function (results) {
debugger;
alert(results.new_name + "" + results.new_Fee.Value + "" + results.new_courseName);
},
_namespace: true
};