Skip to main content

Hi everyone,

I'm trying to do a multi-step automation, where I :

  • find records (questionnaires) using the "Find records" step*
  • feed the records I found as "input variable" to a script
  • use that script to compute values, based on the field "grade" of each "questionnaire" in my "questionnaires" list

My problem :

  • When I try to use the input as "list of record", the input is in fact an HTML string with which it's hard to work :
  •  

  • console.log(questionnaires) => 
  • And it's the same if my input variable is a "grid", the only other option available.

Is there a way I could get a nice, clean JSON as in input instead of this nightmare ?

Thanks 🙏 

 

* I do this instead of scripting my query because the database is huge, and I get out of memory errors when I try script it

Edit :

I solved it (thanks to chatGPT <3) this way :

var myList= [];


const refRegex = /<b>Ref<\/b><br\/>(.*?)<br\/><br\/><br\/>/g;
const gradeRegex = /<b>Grade between 0 to 10<\/b><br\/>(.*?)<br\/><br\/><br\/><span style="display:inline-block;height:1px;width:100%;background-color:#999"> <\/span><br\/>/g;

let refMatch;
let gradeMatch;

while ((refMatch = refRegex.exec(questionnairesHTML)) !== null) {
const ref = refMatch[1].trim();

if ((gradeMatch = gradeRegex.exec(questionnairesHTML)) !== null) {
const grade = parseInt(gradeMatch[1].trim(), 10);

myList.push({ "Ref": ref, "Grade": grade });
}
}

However, it's quite dirty and not resilient (if someone changes the background color of the field, the regex will break ...), so if anyone has a better way I'd love to hear it !

 


You cannot get clean json directly from a Find Records action.

Can you process each record individually or do you need to process the records as a set?

If you can process each record individually, you can use a repeating group. Then use input variables for each individual record.

If you need to process the records as a set, have your input variable be a list of record IDs from the found records. Then have your script query for the records to read the values from the queried records.


Edit :

I solved it (thanks to chatGPT <3) this way :

var myList= [];


const refRegex = /<b>Ref<\/b><br\/>(.*?)<br\/><br\/><br\/>/g;
const gradeRegex = /<b>Grade between 0 to 10<\/b><br\/>(.*?)<br\/><br\/><br\/><span style="display:inline-block;height:1px;width:100%;background-color:#999"> <\/span><br\/>/g;

let refMatch;
let gradeMatch;

while ((refMatch = refRegex.exec(questionnairesHTML)) !== null) {
const ref = refMatch[1].trim();

if ((gradeMatch = gradeRegex.exec(questionnairesHTML)) !== null) {
const grade = parseInt(gradeMatch[1].trim(), 10);

myList.push({ "Ref": ref, "Grade": grade });
}
}

However, it's quite dirty and not resilient (if someone changes the background color of the field, the regex will break ...), so if anyone has a better way I'd love to hear it !

 


Hi,
use 

 


then in code loop both arrays using index parameter
like this

 


Hi,
use 

 


then in code loop both arrays using index parameter
like this

 


It's a great workaround, thanks !


Reply