Re: Comparing 2 scoring fields

Yifat_Danieli
Level 3

Comparing 2 scoring fields

I need to compare 2 scoring fields and if one of them is larger - use a specific rule. Support said it can not be done using Marketo - has anybody found a workaround for this?

17 REPLIES 17
Grégoire_Miche2
Level 10

Re: Comparing 2 scoring fields

Hi Yifat,

We usually do it using Salesforce to do the comparison and returning to Marketo the name of the highest score field.

-Greg

SanfordWhiteman
Level 10 - Community Moderator

Re: Comparing 2 scoring fields

Score arithmetic and aggregation was one of the initial inspirations for FlowBoost.

A short recipe:

var scores = [

  { type: 'behavioral', score: {{Lead.Behavioral Score}} },

  { type: 'demographic', score: {{Lead.Demographic Score}} },

  { type: 'firmographic', score: {{Lead.Firmographic Score}} },

  { type: 'psychographic', score: {{Lead.Psychographic Score}} }

],

highScore = getMax(scores,'score');

function getMax(coll, sortBy){

  return coll.concat().sort(function sortAsc(l,r){

    return sortBy ? l[sortBy] - r[sortBy] : l - r;

  }).pop();

}

(Note in this implementation a tie goes to the later entry in the set of scores, i.e. if Firmographic and Psychographic are both 90, then Psychographic is returned. So you can use the order to determine which one has "seniority.")

Grégoire_Miche2
Level 10

Re: Comparing 2 scoring fields

HI Sanford Whiteman​,

What is FlowBoost?

-Greg

Justin_Norris1
Level 10 - Champion Alumni

Re: Comparing 2 scoring fields

Indeed Sanford Whiteman, tell us more about FlowBoost .

SanfordWhiteman
Level 10 - Community Moderator

Re: Comparing 2 scoring fields

FlowBoost is a full-featured scripting engine that enhances any Marketo flow with the full power of JavaScript. It's called as a webhook and can perform any computation/calculation/parsing you can dream of.

Maybe that doesn't sound cool enough. This is what's really cool: the webhook request is your code:

2016_10_20_02_16_07_Marketo_Webhooks_Admin.pngi

So FlowBoost runs completely headless, turning the Marketo UI into your personal JS interpreter. (The slly example in the pic revereses the lead's first and last name.)

It's actually been running for over a year, but it didn't have a brand name until recently!

If you want more info, you can contact Edward Unthank​.

Justin_Norris1
Level 10 - Champion Alumni

Re: Comparing 2 scoring fields

Another item for the "wish I'd thought of that" list. It's growing pretty long...

That is awesome Sandy and Edward. I look forward to having an opportunity to put it to use.

Justin_Norris1
Level 10 - Champion Alumni

Re: Comparing 2 scoring fields

Sanford Whiteman​ Maybe you should make a library of commonly used functions, or well-documented code snippets that people could easily tweak, so that non-techies could easily put it to use?

SanfordWhiteman
Level 10 - Community Moderator

Re: Comparing 2 scoring fields

We found a stock library doesn't quite fit here, because everybody's needs are just different enough.

It was in the original napkin sketch, but that sketch didn't give users, I think, enough respect for the wide variation of things they want to do.  It was quickly clear that everyone had subtly different needs -- after all, the idea is that you can literally do anything JS can do -- and really MDN and the plethora of code examples around the net are better resources than a falsely restricted set of functions (I often use CodePen for testing 'Boost, since it's just another JS sandbox).

Instead, I'm blogging actively about code recipes (you probably saw my "Code Anatomy" post from today) and how to think about building code with a focus on FlowBoost.  And I also want to use the Community to go over people's needs, provide answers, and hopefully provoke crowdsourced recipes. The more people share their CodePens/jsFiddles/snippets, the better it'll be. Of course, there's a lot of painful-to-read code out there, so I won't hesitate to tell people there's a better way!

That said, when we add a third-party library, like the Google phone number formatter, which isn't so well-documented on the web (well, more like its documentation seems to tilt toward Java peeps rather than JS) or our own function libraries, we'll definitely make sure to break down specifically how to call it.

Yifat_Danieli
Level 3

Re: Comparing 2 scoring fields

Thanks all! will definitely try that FlowBoost recipe - thanks Sanford Whiteman for letting us know about this cool tool!