+ Start a Discussion
mandycmandyc 

Update Related Record via Web Service

I'm trying to update a SelfServiceUser record based on an update to a Contact record. I have an OM configured to call the web service when the contact record is edited. Since I don't have the SSU Id I need to query for it based on the contact Id. I can't seem to figure out how to access the Id from the query. This is my first C# experience. Thanks in advance

 

        EditContactNotification.ContactNotification[] contacts = notifications1.Notification;
        for (int i = 0; i < contacts.Length; i++)
        {
            EditContactNotification.ContactNotification notification = contacts[i];
            EditContactNotification.Contact contact = (EditContactNotification.Contact)notification.sObject;

            EnterpriseWebReference.QueryResult qr = null;
            qr = binding.query("SELECT Id FROM SelfServiceUser WHERE ContactId = " + contact.Id);

            for (int x = 0; x < qr.records.Length; x++)
            {
                EnterpriseWebReference.sObject ssu2Update = qr.records(x);
                EnterpriseWebReference.SelfServiceUser ssu = new EnterpriseWebReference.SelfServiceUser();
                ssu.Id = ssu2Update.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 });
            }
        }
        EditContactNotification.notificationsResponse response = new EditContactNotification.notificationsResponse();
        response.Ack = true;
        return response;

 

the below line generates the following error: Non-invocable member EnterpriseWebReference.QueryResult.records cannot be used like a method.

 

EnterpriseWebReference.sObject ssu2Update = qr.records(x);

 

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

records is an array, so qr.records[x];