Jun 13, 2023 06:05 AM
Hi everyone,
I'm trying to do a multi-step automation, where I :
My problem :
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
Solved! Go to Solution.
Jun 13, 2023 09:43 PM
Jun 13, 2023 06:15 AM
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 !
Jun 13, 2023 09:18 AM
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.
Jun 13, 2023 09:43 PM
Hi,
use
then in code loop both arrays using index parameter
like this
Jun 14, 2023 02:22 AM
It's a great workaround, thanks !