locked
Update WorkerId in QueueItem entity RRS feed

  • Question

  • Hi!

    I'm trying to update WorkerId(in QueueItem) with XrmSvcToolkit.updateRecord and get Success in Return but nothing happens!

    Any good ideas?

    Here is my code:

    function setIncidentWorkedOn(incidentGuid) {
    
        var iGuid = incidentGuid.replace("{", "'").replace("}", "'");
    
        var queueitemid;
        var systemUser;
    
        //Get the QueueItem entity
        var filterQueryQueueItem = "?$filter=ObjectId/Id eq guid" + iGuid;
        XrmSvcToolkit.retrieveMultiple({
            entityName: "QueueItem",
            async: false,
            odataQuery: filterQueryQueueItem,
            successCallback: function (result) {
    
                queueitemid = result[0].QueueItemId;
    
                //Get the user entity
                var uRef = Xrm.Page.context.getUserId();
                XrmSvcToolkit.retrieve({
                    entityName: "SystemUser",
                    id: uRef,
                    async: false,
                    successCallback: function (resultUser) {
    
                        systemUser = resultUser;
                    },
    
                    errorCallback: function (error) {
    
                        alert("Det oppstod en feil, vennligst kontakt EVRY Select SystemUser: " + error.description);
                    }
    
                });
                             
            },
            errorCallback: function (error) {
    
                alert("Det oppstod en feil, vennligst kontakt EVRY. Select QueueItem: " + error.description);
            }
        });
    
        //Update QueueItem - WorkerId attribute with user    
        XrmSvcToolkit.updateRecord({
            entityName: "QueueItem",
            id: queueitemid,
            entity: { WorkerId: systemUser.Id },
            async: false,
            successCallback: function (resultUpdate) {
    
                Xrm.Page.data.entity.save();
    
                alert("Oppdatert OK - QueueItemId: " + queueitemid + " - UserName: " + systemUser.FullName);
    
            },
    
            errorCallback: function (error) {
    
                alert("Det oppstod en feil, vennligst kontakt EVRY. Update QueueItem: " + error.description);
    
            }
    
        });
    }
    BR Knut
    
    Wednesday, April 9, 2014 1:41 PM

Answers

  • I though this one was "answered":-) But thanks anyway! This code works:

    function setIncidentWorkedOn(incidentGuid) {
    
        var iGuid = incidentGuid.replace("{", "'").replace("}", "'");
    
        var queueitemid;
    
        //Get the QueueItem entity
        var filterQueryQueueItem = "?$filter=ObjectId/Id eq guid" + iGuid;
        XrmSvcToolkit.retrieveMultiple({
            entityName: "QueueItem",
            async: false,
            odataQuery: filterQueryQueueItem,
            successCallback: function (result) {
                queueitemid = result[0].QueueItemId;
            },
            errorCallback: function (error) {
                alert("Error Select QueueItem: " + error.description);
            }
        });
    
        //Update QueueItem - WorkerId attribute with user   
        var contextUserId = Xrm.Page.context.getUserId();
        XrmSvcToolkit.updateRecord({
            entityName: "QueueItem",
            id: queueitemid,
            entity: {
                WorkerId: {
                    Id: contextUserId,
                    LogicalName: "systemuser"
                }
            },
            async: false,
            successCallback: function (result) {
            },
            errorCallback: function (error) {
                alert("Error Update QueueItem: " + error.description);
            }
    
        });
    }

    • Marked as answer by knutmyre Thursday, August 28, 2014 7:53 AM
    Thursday, August 28, 2014 7:53 AM

All replies

  • Try this

    var queueItem = new XrmServiceToolkit.Soap.BusinessEntity("queueitem", queueitemid);            
    
    queueItem.attributes["workerid"] = { id: systemUser.Id, logicalName: "systemuser", type: "EntityReference" };
    
    XrmServiceToolkit.Soap.Update(updateLineItem);

    Wednesday, August 27, 2014 7:03 PM
  • I though this one was "answered":-) But thanks anyway! This code works:

    function setIncidentWorkedOn(incidentGuid) {
    
        var iGuid = incidentGuid.replace("{", "'").replace("}", "'");
    
        var queueitemid;
    
        //Get the QueueItem entity
        var filterQueryQueueItem = "?$filter=ObjectId/Id eq guid" + iGuid;
        XrmSvcToolkit.retrieveMultiple({
            entityName: "QueueItem",
            async: false,
            odataQuery: filterQueryQueueItem,
            successCallback: function (result) {
                queueitemid = result[0].QueueItemId;
            },
            errorCallback: function (error) {
                alert("Error Select QueueItem: " + error.description);
            }
        });
    
        //Update QueueItem - WorkerId attribute with user   
        var contextUserId = Xrm.Page.context.getUserId();
        XrmSvcToolkit.updateRecord({
            entityName: "QueueItem",
            id: queueitemid,
            entity: {
                WorkerId: {
                    Id: contextUserId,
                    LogicalName: "systemuser"
                }
            },
            async: false,
            successCallback: function (result) {
            },
            errorCallback: function (error) {
                alert("Error Update QueueItem: " + error.description);
            }
    
        });
    }

    • Marked as answer by knutmyre Thursday, August 28, 2014 7:53 AM
    Thursday, August 28, 2014 7:53 AM