goservicenow-rest-api

servicenow-sdk-go Access TableEntry's display_value


Trying to use the tableapi of servicenow-go-sdk to retrieve a list of affected CIs from a given CM.

rb := tableapi.NewTableRequestBuilder(client, map[string]string{
  "table": "task_cmdb_ci_service",
  "baseurl": "...",
})

records, err := rb.Get(&tableapi.TableRequestBuilderGetParameters{
  Query: "task=my_sys_id",
  DisplayValue: tableapi.TRUE,
})

At this point, logging out records.Result does show the values I'm looking for :

&map[cmdb_ci_service:map[display_value:<What I want is here> ...] ...]

Unfortunately, I can't figure out how to access it. TableEntry has a .Value() accessor, but when it finds a map it just goes and tries to grab "value" from it, and in my case what I want is display_value. I've tried manually converting the TableEntry back to a map, but I can't get that to work either.

Any idea, am I doomed to ditch that lib and interact with the snow API manually ? Thanks


Solution

  • Figured out a solution, setting ExcludeReferenceLink: true in the query parameters gets rid of the internal map, which makes the lib return the display_value.

    Not sure what you'd do if you needed that link, but thankfully I don't so I'm set