You need to sign in to do that
Don't have an account?
mandyc
Update Self-Service User Record
I would like to update a Self-Service User record via an OM when the related contact record is updated. The below code is generating the following error: Object reference not set to an instance of an object.
I appreciate the help!
for (int i = 0; i < contacts.Length; i++) { EditContactNotification.ContactNotification notification = contacts[i]; EditContactNotification.Contact contact = (EditContactNotification.Contact)notification.sObject; EnterpriseWebReference.QueryResult qr = null; try { qr = binding.query("SELECT Id FROM SelfServiceUser WHERE ContactId = " + contact.Id); } catch (System.Exception e) { Console.WriteLine("Query didn't work " + e.Message); } if (qr.size > 0) { EnterpriseWebReference.sObject[] records = qr.records; for (int x = 0; x < records.Length; x++) { EnterpriseWebReference.SelfServiceUser var = ((EnterpriseWebReference.SelfServiceUser)records[x]); EnterpriseWebReference.SelfServiceUser ssu = new EnterpriseWebReference.SelfServiceUser(); ssu.Id = var.Id; ssu.ContactId = contact.Id; ssu.FirstName = contact.FirstName; ssu.LastName = contact.LastName; ssu.Username = contact.Email; ssu.Email = contact.Email; EnterpriseWebReference.SaveResult[] saveResults = binding.update(new EnterpriseWebReference.sObject[] { ssu }); }
I still don't know how to debug my code but I figured out the issue. I was setting the contact Id in my original update code and once I took that out everything started working. Here is my functioning code for anyone trying to update a Self Service User account in the future.
All Answers
On which line?
I've refactored my code a bit and I am no longer receiving an error; however, my SSU is not updating either.
Here is my current code. This is my first C# web service so I'm not sure how best to debug the code. I'm not sure if I'm getting a result from the query or not. Any suggestions you have are appreciated!
You call binding.update, but don't check the returned saveResult, if that chunk of code is actually getting called,then that'll tell you why the update failed. You should probably add more logging for the query response to make it easier to debug.
Can you send me an example of how I might add the additional logging? Will I see the log information on the OM Delivery Status screen?
Thank you
I still don't know how to debug my code but I figured out the issue. I was setting the contact Id in my original update code and once I took that out everything started working. Here is my functioning code for anyone trying to update a Self Service User account in the future.