Skip to main content

JSON script

  • March 24, 2024
  • 3 replies
  • 44 views

Forum|alt.badge.img+4

Hi, I need to create a script that generates a JSON with the information of a record, I have done many tests but I get stuck with the easiest thing, assign the values of the fields to the JSON. Any idea of help or example, thanks a lot.

 

let inputConfig = input.config()

let table = base.getTable("CONTRATOS");
let record = inputConfig.recordId;

// Seleccionar registro de la tabla
const row_rec = await table.selectRecordAsync(record)

// Extraer los campos correspondientes
const codigo = row_rec.getCellValueAsString("Codigo")


const token = ''

const body = {
"strBodyRequest": {
"BPCode": {
"fuente":"CONTRATOS.Código (from Cliente) (from Venta)",
"valor":codigo
},
},
 
}

const options = {
method: 'POST',
headers: new Headers({ 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' }),
body: JSON.stringify(body)
}

let response = await fetch(url, options);
const result = await response.json();

console.log(`Got ${response.status} with body ${JSON.stringify(result)}`);

3 replies

ScottWorld
Forum|alt.badge.img+35
  • Genius
  • March 24, 2024

Okeowo_Aderemi
Forum|alt.badge.img+3
  • Participating Frequently
  • April 2, 2024

@Jose_Martinez1 Do you mean it should fetch all the fields in a record and value and turn them to JSON ? 


Forum|alt.badge.img+4
  • Author
  • New Participant
  • April 2, 2024

@Jose_Martinez1 Do you mean it should fetch all the fields in a record and value and turn them to JSON ? 


Hi @Okeowo_Aderemi , is correct  Thk