@@ -349,7 +349,7 @@ func enrichRecordShareResolveHint(runtime *common.RuntimeContext, out map[string
349349 hint := map [string ]interface {}{}
350350 if baseToken != "" && tableID != "" && recordID != "" {
351351 if record , err := getResolveRecord (runtime , baseToken , tableID , recordID ); err == nil {
352- hint ["record" ] = record
352+ hint ["record" ] = formatResolvedRecord ( record )
353353 }
354354 }
355355 if baseToken != "" && tableID != "" {
@@ -366,6 +366,50 @@ func getResolveRecord(runtime *common.RuntimeContext, baseToken, tableID, record
366366 return handleBaseAPIResult (result , err , "batch get records" )
367367}
368368
369+ func formatResolvedRecord (record map [string ]interface {}) map [string ]interface {} {
370+ recordIDs := common .GetSlice (record , "record_id_list" )
371+ fieldIDs := common .GetSlice (record , "field_id_list" )
372+ fieldNames := common .GetSlice (record , "fields" )
373+ rows := common .GetSlice (record , "data" )
374+
375+ out := map [string ]interface {}{}
376+ if len (recordIDs ) > 0 {
377+ out ["record_id" ] = fmt .Sprintf ("%v" , recordIDs [0 ])
378+ }
379+
380+ data := map [string ]interface {}{}
381+ if len (rows ) > 0 {
382+ if values , ok := rows [0 ].([]interface {}); ok {
383+ for i , value := range values {
384+ data [resolvedRecordFieldKey (fieldIDs , fieldNames , i )] = value
385+ }
386+ }
387+ }
388+ out ["data" ] = data
389+ return out
390+ }
391+
392+ func resolvedRecordFieldKey (fieldIDs , fieldNames []interface {}, index int ) string {
393+ fieldID := ""
394+ if index < len (fieldIDs ) {
395+ fieldID = strings .TrimSpace (fmt .Sprintf ("%v" , fieldIDs [index ]))
396+ }
397+ fieldName := ""
398+ if index < len (fieldNames ) {
399+ fieldName = strings .TrimSpace (fmt .Sprintf ("%v" , fieldNames [index ]))
400+ }
401+ switch {
402+ case fieldID != "" && fieldName != "" :
403+ return fmt .Sprintf ("%s(%s)" , fieldID , fieldName )
404+ case fieldID != "" :
405+ return fieldID
406+ case fieldName != "" :
407+ return fieldName
408+ default :
409+ return fmt .Sprintf ("field_%d" , index + 1 )
410+ }
411+ }
412+
369413func resolveHint (tableID string , extra map [string ]interface {}) map [string ]interface {} {
370414 hint := map [string ]interface {}{}
371415 for key , value := range extra {
0 commit comments