Select to view content in your preferred language

Text widget - dynamic text - how to format date to dd/mm/yy

154
1
Saturday
elpinguino
Frequent Contributor

Hi ExBers,

It's been a while since I've been back using ExB, and I see there's a few improvements that have been made.

I have a date field in a hosted table that I have connected up to a text widget. The date is outputting as dd/m/yy so for 24 May 2026 it outputs as 24/5/26. I want it to output as dd/mm/yy though ie 24/05/26. This should be the case for any single digit month to have a 0 in front of it.

I thought it would be as simple as text($feature.fieldname,'dd/mm/yy'), but when I go into Arcade script there's a whole bunch of other stuff going on that I'm not familiar with. Is anyone able to provide some guidance? It doesn't seem to like $feature or $datasource.

This is the default Arcade script.

// Documentation: https://arcg.is/18ejKn3

function getFilteredFeatureSet(ds) {
  var result = ds.layer;
  var queryParams = ds.queryParams;

  if (!IsEmpty(queryParams.where)) {
    result = Filter(result, queryParams.where);
  }

  if (!IsEmpty(queryParams.geometry)) {
    result = Intersects(result, queryParams.geometry);
  }

  return result;
}
 
// The filteredFeatureSet1 has already been filtered using spatial filters and attribute filters.
// var filteredFeatureSet1 = getFilteredFeatureSet($dataSources["dataSource_2-0"]);
// selectedFeatures1 is the selection view of data source.
// var selectedFeatures1 = $dataSources["dataSource_2-0"].selectedFeatures;


// NOTE: When using selectedFeatures, cases with no selected features must be handled manually.


return {
  value: '',
  text: {
    // size: 14,
    // color: 'rgb(0, 0, 255)',
    // bold: true,
    // italic: false,
    // underline: false,
    // strike: false
  },
};
0 Kudos
1 Reply
ShengdiZhang
Esri Regular Contributor

Hi @elpinguino ,

If the text widget is not in a list, it can only use the profile $dataSources, similar to $layer. However, if you select a text widget inside a list, you can use $feature.

Thanks,

Shengdi

0 Kudos