Modifying a Lookup’s Configuration To Include Additional Columns in the Results in Creatio (formerly bpm’online)

I wrote an article previously outlining how to modify a lookup’s filter via code. See Filtering Lookups in Creatio. In that article I show how to add an attribute that merges with the lookup, modifying the lookupListConfig for the lookup to add a filter. You can use that same approach to modify other things about the lookup. For example, we can tell it to add additional columns from the object the lookup is for so we can use those without needing to do an EntitySchemaQuery to get them.

For example, let’s say you have a Contact lookup. On the page where you have this contact lookup, you also want to get the selected contact’s email address and phone number. You *could* just use an EntitySchemaQuery, get the selected contact and then go read the Email and Phone column values from that record. However, to save the extra steps, you could just add Email and Phone as a column in the data returned by the lookup. To do that we will add the following attribute. As I mentioned in the previous article, the name of the attribute needs to be the same name as our lookup column name.

 attributes: {
  "UsrContact": {
    lookupListConfig: {
        columns: ["Email", "Phone"]
    }
  }
}

With that in place, our lookup will always include the Email column in the result. I am not referring to adding these columns in the lookup dialog itself so the user can see it. I am referring to when you get the value from the lookup it will include the Email & Phone values from the selected Contact. Meaning, we can do this:

var contact = this.get("UsrContact");
// normally we will have just value & displayValue for this object
var id = contact.value;
// now, our contact object will include email and phone as well
var email = contact.Email;
var phone = contact.Phone

Using attributes allows you to extend, or add to, the configuration of the lookup. As a aide note, we’ve looked at filters and columns, you can also set an order for the results as well. For example, to order by name:

 attributes: {
  "UsrContact": {
    lookupListConfig: {
        orders: [{columnPath: "Name"}]
    }
  }
}

Of course, you can combine all of filters, columns, and orders for a lookup as needed.

ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!