Search code examples
c#.netservicenow

ServiceNow - getting the display name from assignedto field


I am getting the assignedto field as d7ec53d80f0a650000af0bcce1050ea2. Instead, I need to get the user display name. How to get the display name for assignedto in ServiceNow - Release Management

Web Reference Url = https://*****.service-now.com/rm_story.do?WSDL

Code:

            var url = "https://*****.service-now.com/rm_story.do?SOAP";
            var userName = *****;
            var password = *****;

            var proxy = new ServiceNow_rm_story
            {
                Url = url,
                Credentials = new NetworkCredential(userName, password)
            };

            try
            {
                var objRecord = new Namespace.WebReference.getRecords
                {
                    // filters..
                };

                var recordResults = proxy.getRecords(objRecord);
            }
            catch (Exception ex)
            {

            }

In recordResults from the code above, I am able to enumerate and get the assignedto field, but the value is displaying in ( some guid or unknown format - example - d7ec53d80f0a650000af0bcce1050ea2) pattern. I need to get the display name.

How to get the display name for assignedto field ?


Solution

  • AssignedTo is a reference field, and the d7ec53d80f0a650000af0bcce1050ea2 value you are seeing is the sys_id (uuid) of the user the rm_story is assigned to. Instead you want the display value which you can get by adding 'displayvalue=true' to your SOAP request URL. You can also specify 'displayvalue=all' to have both the sys_id and the display value returned in the soap response. Check out the ServiceNow SOAP Web Service docs (link) for additional info and sample. Hope that helps.

    If using REST instead of SOAP is an option I would recommend checking out ServiceNow REST Table API and using the REST API Explorer to help you build your HTTP Requests and easily specify parameters like display value.

    REST API Explorer REST Table API