Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Highlighted
Copper Contributor
Posts: 69
Registered: ‎05-07-2012

SData How to set AssignedToId in a Ticket?

[ Edited ]

This SData is driving me crazy!!

 

We're creating a project portal. The single steps sould be synced to SalesLogix as tickets because interacting with the customers.

 

I've wrote some .Net code to create new tickets. I've got a Payload in there to set the single values:

 

ticketPayload.Values["Account"= _sDataTools.GetEntityPayload("accounts", ticketToCreate.AccountId);
            ticketPayload.Values["Contact"= _sDataTools.GetEntityPayload("contacts", ticketToCreate.ContactId);
            ticketPayload.Values["UrgencyCode"= (int) ticketToCreate.UrgencyCode; //ENUM
            ticketPayload.Values["UrgencyId"= _sDataTools.GetTicketUrgencyId(ticketToCreate.UrgencyCode.ToString());
            ticketPayload.Values["ReceiveDate"= ticketToCreate.ReceivedDate;
            ticketPayload.Values["PublicAccessCode"= ticketToCreate.PublicAccessCode;
            ticketPayload.Values["StatusCode"= ticketToCreate.StatusCode;
            ticketPayload.Values["Subject"= ticketToCreate.Subject;

 This is working fine.

Now the problems:
I have to set the SeccodeId (Owner) to a ID "A" for example.
We need AssignetToId and ReceivedById which are getting assinged through code in that new portal.

As this seems not be possible to do this in the Create step, I've desided to do an update to this ticket:

internal void SetSeccodes(string ticketId, Ticket ticketToCreate)
        {
            var sDataSingleResourceRequest = new SDataSingleResourceRequest(_dynamicInstance)
            {
                ResourceKind = "tickets"
            };
 
            var sDataResourceCollectionRequest = new SDataResourceCollectionRequest(_dynamicInstance)
            {
                ResourceKind = "tickets",
                StartIndex = 1,
                Count = 1
            };
            sDataResourceCollectionRequest.QueryValues.Add("where"string.Format("Id eq '{0}'", ticketId));
 
            var atomFeed = sDataResourceCollectionRequest.Read();
 
            var receivedBy = _sDataTools.GetEntityPayload("owners", ticketToCreate.ReceivedByUserId);
            var assignedTo = _sDataTools.GetEntityPayload("owners", ticketToCreate.AssignedToUserId);
            var owner = _sDataTools.GetEntityPayload("owners", ticketToCreate.OwnerId);
 
            foreach (var entry in atomFeed.Entries)
            {
                var sDataPayload = entry.GetSDataPayload();
                sDataSingleResourceRequest.Entry = entry;
                sDataSingleResourceRequest.ResourceSelector = string.Format("'{0}'", ticketId);
 
                sDataPayload.Values["ReceivedBy"= receivedBy;
                sDataPayload.Values["AssignedTo"= assignedTo;
                sDataPayload.Values["Owner"= owner;
 
                sDataSingleResourceRequest.Update();
            }
        }

 Doing this, my Owner is set to the Id which is provieded in the payload "assignedTo".
ReceivedBy and AssignedTo are set to the SeccodeId of the User which is logged on to SData.

 

Where is the problem in here??