Quantcast
Channel: Forum CRM Development
Viewing all articles
Browse latest Browse all 1000

crm 2011 ajax REST set state and status code

$
0
0

I'm trying to set a queue item as inactive by changing the state and status but nothing is happening. Any ideas?

As the code is written now it will return an error that says that the ‘2’ is not a valid state for the QueueItemState.Active.

If I just use the StateCode = {Value:1} nothing happens and it returns a success message?

Code:

function queueItem_SetInactive(queueitemID) {
    queueitemID = "{476EEC61-DAC2-E211-A44A-AC162D7F555C}";
    includeJS("../WebResources/sample_/Scripts/jquery1.4.1.min.js");
    includeJS("../WebResources/sample_/Scripts/json2.js");
    includeJS("../WebResources/sample_/Scripts/SDK.JQuery.js");

    var queueItem = {};
    queueItem.StateCode = { Value: 1};
    queueItem.StatusCode = { Value: 2 };

    var errorHandler = function (error) {
        alert(error.message);
    };

    alert("UPDATING RECORD");

    SDK.JQuery.updateRecord(
        queueitemID,
        queueItem,
        "QueueItem",
        function () {
            alert("The object is now inactive!");
        },
        errorHandler
    );
}

function includeJS(p_file) {
    try {
        var jsfile = document.createElement('script');
        jsfile.type = 'text/javascript';
        jsfile.src = p_file;
        document.getElementsByTagName('body')[0].appendChild(jsfile);
    } catch (err) { alert("Function: includeJS returned an error: \r\n" + err.message);}
}


Viewing all articles
Browse latest Browse all 1000

Trending Articles



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