I have created a Widget that displays one property of an object. If I select a text property it works just fine, however I want to display a composite. In this case the mats.Search returns a long hexadecimal string - which if I decode it looks like the references to the individual fields in the composite. How do I get the text value of the composite in the same way as I do a text property? My code is:
var selects = {};
selects.somefield1 = field1;
var result = mats.search({
‘record_id’: id,
‘selects’: selects,
‘return’: ‘value’
});
mats.log ("Result is " + JSON.stringify(result));
id is the recordid which is presumably correct as it works for a text field.
field1 is a reference to the field, which also works for the text field.
To add to that - if ‘selects’ in your example is a single field (and not an object) then the return value will be just the resolved value, too. Cleaner, depending on your specific circumstances. So using your full example:
var select = mats.ref('my_field');
// ^ will be a string this time, not an object
var result = mats.record(id)
var displayable_field_value = result.get(select, 'displayable');
// ^ gives you just a single, usable value