I'm building a webhook in Marketo using a tool called Flowboost. Essentially this tool will run a webhook through their backend and update certain fields in the Marketo software.
What I'm trying to do is update a field in Marketo as long as the corresponding field matches what is in the CSV file.
For example: SKills Assessment (An attribute field in Marketo) is X. Then I need it to match the field in the CSV file and push the corresponding data in the CSV file to Skills Assessment URL (Another attribute field in Marketo).
It's a find and replace function, but I'm struggling with if Skills Assessment = X then Skills Assessment URL should = Y and how to push that data back up.
I know this is more of an intermediate type of function so I'm kind of guessing right now. This what I have so far:
var skills = {{lead.Skills Assessment}}
var skillsURL = {{lead.Skills Assessment Url}};
FBHttp.fetch( "https://get.pluralsight.com/rs/306-DUP-745/images/Skills_Assessments_URLs.csv" )
.then( FBText.CSV.autoParse )
.then( rows =>
rows.find( row => row.skillsAssessment === skills)
rows.find(row => row.skillsAssessmentUrl)
)
.then (
skills[skills.findIndex(el => el.skillsAssessmentUrl === skillsURL.skillsAssessmentUrl)] = skillsURL;
)
.then ( success )
This is a Flowboost function FBHttp.fetch( "https://get.pluralsight.com/rs/306-DUP-745/images/Skills_Assessments_URLs.csv" ) .then( FBText.CSV.autoParse ) that does the following: FBText.CSV.autoParse = function (textable) { FBText.CSV.DETECT_TYPES = false;
var rows = typeof textable.text == "function"
? rows = textable.text().then(FBText.CSV.parse)
: rows = Promise.resolve(FBText.CSV.parse(textable));
return rows.then(parsedRows => {
var headers = parsedRows.shift(),
data = parsedRows;
return data.map(row => row.reduce((acc, nextCol, colIdx) => {
acc[headers[colIdx]] = nextCol;
return acc;
}, {})
);
});
};