Curd Operations Using XrmServiceToolkit

var entity = {};
entity.new_Currency = { Value: parseFloat(123).toFixed(4) };
entity.new_Customer = {
    Id: "21323424434",
    LogicalName: "account"
};
entity.new_DataandTime = new Date("10/18/2017").toLocaleString();
entity.new_DecimalNumber = parseFloat(2132144).toFixed(2);
entity.new_FloatPointNumber = parseFloat(232.432).toFixed(2);
entity.new_Lookup = {
    Id: "23234324",
    LogicalName: "account"
};
entity.new_MultiLineTextBox = "test";
entity.new_OptionSet = { Value: 3 };
entity.new_SIngleLineTExt = "tesxt";
entity.new_TwoOption = true;
entity.new_WholeNumber = 21342;

XrmServiceToolkit.Rest.Create(
    entity,
    "AccountSet",
    function (result) {
        var newEntityId = result.AccountId;
    },
    function (error) {
        alert(error.message);
    },
    false
);

var entity = {};
entity.new_Currency = { Value: parseFloat(123).toFixed(4) };
entity.new_Customer = {
    Id: "21323424434",
    LogicalName: "account"
};
entity.new_DataandTime = new Date("10/18/2017").toLocaleString();
entity.new_DecimalNumber = parseFloat(2132144).toFixed(2);
entity.new_FloatPointNumber = parseFloat(232.432).toFixed(2);
entity.new_Lookup = {
    Id: "23234324",
    LogicalName: "account"
};
entity.new_MultiLineTextBox = "test";
entity.new_OptionSet = { Value: 3 };
entity.new_SIngleLineTExt = "tesxt";
entity.new_TwoOption = true;
entity.new_WholeNumber = 21342;

XrmServiceToolkit.Rest.Update(
    "",
    entity,
    "AccountSet",
    function () {
        alert("Updated"); //Success - No Return Data - Do Something
    },
    function (error) {
        alert(error.message);
    },
    false
);

XrmServiceToolkit.Rest.Delete(
    "1234567",
    "AccountSet",
    function () {
        alert("Deleted"); //Success - No Return Data - Do Something
    },
    function (error) {
        alert(error.message);
    },
    false
);

XrmServiceToolkit.Rest.Retrieve(
    "1234343554544456",
    "AccountSet",
    "new_Currency,new_Customer,new_DataandTime,new_DecimalNumber,new_FloatPointNumber,new_Lookup,new_MultiLineTextBox,new_OptionSet,new_SIngleLineTExt,new_TwoOption,new_WholeNumber",
    null,
    function (result) {
        var new_Currency = result.new_Currency;
        var new_Customer = result.new_Customer;
        var new_DataandTime = result.new_DataandTime;
        var new_DecimalNumber = result.new_DecimalNumber;
        var new_FloatPointNumber = result.new_FloatPointNumber;
        var new_Lookup = result.new_Lookup;
        var new_MultiLineTextBox = result.new_MultiLineTextBox;
        var new_OptionSet = result.new_OptionSet;
        var new_SIngleLineTExt = result.new_SIngleLineTExt;
        var new_TwoOption = result.new_TwoOption;
        var new_WholeNumber = result.new_WholeNumber;
    },
    function (error) {
        alert(error.message);
    },
    false
);

XrmServiceToolkit.Rest.RetrieveMultiple(
    "AccountSet",
    "?$select=new_Currency,new_Customer,new_DataandTime,new_DecimalNumber,new_FloatPointNumber,new_Lookup,new_MultiLineTextBox,new_OptionSet,new_SIngleLineTExt,new_TwoOption,new_WholeNumber&$top=10000",
    function (results) {
        for (var i = 0; i < results.length; i++) {
            var new_Currency = results[i].new_Currency;
            var new_Customer = results[i].new_Customer;
            var new_DataandTime = results[i].new_DataandTime;
            var new_DecimalNumber = results[i].new_DecimalNumber;
            var new_FloatPointNumber = results[i].new_FloatPointNumber;
            var new_Lookup = results[i].new_Lookup;
            var new_MultiLineTextBox = results[i].new_MultiLineTextBox;
            var new_OptionSet = results[i].new_OptionSet;
            var new_SIngleLineTExt = results[i].new_SIngleLineTExt;
            var new_TwoOption = results[i].new_TwoOption;
            var new_WholeNumber = results[i].new_WholeNumber;
        }
    },
    function (error) {
        alert(error.message);
    },
    function () {
        //On Complete - Do Something
    },
    false
);

XrmServiceToolkit.Rest.Associate(
    "121323443454565667",
    "AccountSet",
    "65444332421321",
    "TaskSet",
    "",
    function () {
        alert("Associated"); //Success - No Return Data - Do Something
    },
    function (error) {
        alert(error.message);
    },
    false
);

XrmServiceToolkit.Rest.Disassociate(
    "121323443454565667",
    "AccountSet",
    "65444332421321",
    "",
    function () {
        alert("Disassociated"); //Success - No Return Data - Do Something
    },
    function (error) {
        alert(error.message);
    },
    false
);

Comments

Popular posts from this blog

Meta Data Using WebApiRequest

Sample CRUD Operations Using C# in MSCRM

Basic Plugin Code in D365 using C#