Skip to main content
Version: main

Update table record

Overview

Updates the specified record by sys_id in the specified table.

Path parameters

NameDescription
tableThe table name for the operation.
sysIdThe sys id of the table record.

Optional query parameters

NameTypePossible valuesDescription
DisplayValuetableapi.DisplayValueDisplayValueTrue, DisplayValueFalse, or DisplayValueAllDetermines the type of data returned, either the actual values from the database or the display values of the fields.
ExcludeReferenceLinkboolN/AFlag that indicates whether to exclude Table API links for reference fields.
Fields[]string N/AList of fields to include in the response.
InputDisplayValueboolN/AFlag that indicates whether to set field values using the display value or the actual value.
QueryNoDomainboolN/AFlag that indicates whether to restrict the record search to only the domains configured for the logged in user.
Viewtableapi.ViewViewDesktop, ViewMobile, or ViewBothUI view for which to render the data.

Required query parameters

N/A

Examples

package main

import (
"context"
"fmt"
"log"

servicenowsdkgo "github.com/michaeldcanady/servicenow-sdk-go/v2"
tableapi "github.com/michaeldcanady/servicenow-sdk-go/v2/tableapi"
)

func main() {
// Step 1: Create credentials
cred := credentials.NewBasicProvider("{username}", "{password}")
// Step 2: Initialize client
client, err := servicenowsdkgo.NewServiceNowServiceClient(
servicenowsdkgo.WithAuthenticationProvider(cred),
servicenowsdkgo.WithURL("https://{instance}.service-now.com"),
)
if err != nil {
log.Fatal(err)
}
// Step 3: Configure request
updateConfig := &tableapi.TableItemRequestBuilderPutRequestConfiguration{
QueryParameters: &tableapi.TableItemRequestBuilderPutQueryParameters{
// Optional configurations
},
}

// Step 4: Build request body
updateData := tableapi.NewTableRecord()
if err := updateData.SetValue("short_description", "updated incident"); err != nil {
log.Fatal(err)
}

// Step 5: Execute request
updateResponse, err := client.Now().Table("{TableName}").ByID("{SysID}").Put(context.Background(), updateData, updateConfig)
if err != nil {
log.Fatal(err)
}
}
Was this page helpful?