web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Update WorkerId in QueueItem entity with JavaScript

(0) ShareShare
ReportReport
Posted on by

Hi!

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

Any good ideas what I'm doing wrong?

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(error.description);

               }

           });

       },

       errorCallback: function (error) {

           alert(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("Success!");

               } ,

        errorCallback: function (error) {

           alert(error.description);

       }

   });

}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hello Knut,

    you colud try to remove " ' " from replace function and to put only ""

    Also you could to try to update a simple field as a string field... only for test.

    Let me know,

    Thanks

  • Community Member Profile Picture
    on at

    Thanks a lot for answers!

    I had to an adjustment, this code Works Perfect:

    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("Det oppstod en feil, vennligst kontakt EVRY. Update QueueItem: " + error.description);

           }

       });

    Cheers:-)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans