2
1
0

If I have an auto-complete field which works nicely with a defined map, how do I then access other properties in the selected value.

I currently have:

1) A map:

data.$mccCodeData = [
  {
    "MCC": 742,
    "Description": "VETERINARY SERVICES",
    "label": "742 VETERINARY SERVICES"
  },
  {
    "MCC": 763,
    "Description": "AGRICULTURAL CO-OPS",
    "label": "763 AGRICULTURAL CO-OPS"
  },
  {
    "MCC": 780,
    "Description": "HORTICULTURAL AND LANDSCAPING SERVICES",
    "label": "780 HORTICULTURAL AND LANDSCAPING SERVICES"
  } ....

 

2) An autocomplete field which references "label" as the trigger property name and suggestion list name (This functions as expected)

3) A third field which tries to return the Description.

 

What I have is a situation where, in my third field calculation:

data.mccCode

works just fine

 

...but this doesn't return a value:

data.mccCode.Description
  1. David Moore

    Please provide me with the form details Sacha.

  2. Sacha Trube

    https://tm.maestro.avoka.com/maestro/secure/design/3274 Page: Company Infomration then page: Business Details -> Business Description calculation.

CommentAdd your comment...

1 answer

  1.  
    1
    0
    -1

    There isn't currently a convenience method for this case, so you'll have to code a lookup in JavaScript as follows:

    var mcc = (data.$mccCodeData || []).filter(function(mcc) {
      return mcc.label === data.mccCode;
    })[0];
    return mcc ? mcc.Description : "Unselected";

     

    I have made a new version of your form with this in, at:

    https://tm.maestro.avoka.com/maestro/secure/design/3274

     

    I couldn't find where you're trying to get the description so I made a new field for it next to the MCC code autocomplete.

     

    Note that in your case there is a simpler way to derive the description by removing the number from the front of the label, using something like:

    data.mccCode.substr(data.mccCode.search(" ") + 1)

     

    or:

    data.mccCode.split(" ").splice(0, 1).join(" ")

      CommentAdd your comment...