Help

Re: JSON script

1091 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Jose_Martinez1
5 - Automation Enthusiast
5 - Automation Enthusiast

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 3
ScottWorld
18 - Pluto
18 - Pluto
Okeowo_Aderemi
4 - Data Explorer
4 - Data Explorer

@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