I have a table with two columns: Url and QR Code. I would like to run a script that will modify the QR Code field when the Url field changes.
I created an automation that fires a script when the Url changes. I'm trying to determine how to modify the QR Code in the row that changed.
The script:
/**
* Generate a QR code from text, using QuickChart.io (https://quickchart.io/documentation/qr-codes/)
* @param {string} text The text to be converted.
* @returns {string} The QR code's URI
*/
const getQrCodeUri = ( text ) => {
const serialize = function(obj) {
var str = [];
for (var p in obj)
if (obj.hasOwnProperty(p)) {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
}
return str.join("&");
}
const settings = {
text: text,
size: 150,
margin: 4,
dark: 'f00',
light: '0ff',
ecLevel: 'Q',
format: 'svg'
}
const qs = serialize(settings)
const baseUri = 'https://quickchart.io/qr'
const uri = `${ baseUri }?${ qs }`
return uri;
}
// input variables
let inputConfig = input.config();
let url = inputConfig.url;
// calculate QR code
const qrCodeUrl = getQrCodeUri(url);
console.log('qrCodeUrl',qrCodeUrl)
// update the QR Code field
?
Do I pass the QR Code field as an input, then set its value or is there more to it?