<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get field by alias in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298939#M27462</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If I understand you right, you want to display the alias field name for your data? As far as I know, you still need to use the actual name in the infotemplate, but there are a couple of ways to do it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If it's a featurelayer, you can get the alias from the fields property.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/featurelayer.htm#fields" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/featurelayer.htm#fields&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which is an array of fields&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/field.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/field.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can then iterate the array, find the value you want and apply it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;something like&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var content = "";
for (var i=0, field; field = fields&lt;I&gt;; i++) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (field.alias == "TARGET") {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp = field.alias + ": ${" + field.name + "}";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; content += tmp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}
&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If not a featurelayer, you can use esri.request to get the field information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var handle = esri.request({
&amp;nbsp;&amp;nbsp;&amp;nbsp; url: "URLPATH",
&amp;nbsp;&amp;nbsp;&amp;nbsp; content: {"f" : "json"},
&amp;nbsp;&amp;nbsp;&amp;nbsp; handleAs: "json"
});

handle.then(function(result){
&amp;nbsp;&amp;nbsp;&amp;nbsp; var fields = result.fields;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // do your iteration to get template data here
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure if that's exactly the solution you are looking for, but I have a similar situtaion with a layer that has a join where I want to display the alias and not the long sde.dbo.blahblah name and this is similiar to how I do it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 14:21:17 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2021-12-11T14:21:17Z</dc:date>
    <item>
      <title>Get field by alias</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298934#M27457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm newbie javascript arcgis and i'm in doubt how do i get a field of my layer via alias.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I can get a field in two ways:&lt;BR /&gt;&lt;BR /&gt;value of field is: ${field_name}'&lt;BR /&gt;&lt;BR /&gt;or &lt;BR /&gt;&lt;BR /&gt;graphic.attributes.field_name&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But the field name is too long, so I want to get the field using alias&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can someone help-me?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 18:12:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298934#M27457</guid>
      <dc:creator>raphael_hernandesguimenes</dc:creator>
      <dc:date>2012-05-22T18:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: Get field by alias</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298935#M27458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This should be possible, but can you provide more information - where are you attempting to get the field name (eg when running an Identify, when formatting the results of an infoWindow, etc)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you working with a feature layer, dynamic layer, graphic, etc?&amp;nbsp; Do you have any sample code showing the problem you're facing?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This may help to show where/how to obtain the field via its alias in your circumstances.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 20:57:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298935#M27458</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2012-05-22T20:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: Get field by alias</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298936#M27459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, thank you for your reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to show the fields within a infowindow. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;infoWindow.setTitle('${my_field_via_alias}');&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This infoWindow will be used with a featureLayer that uses join on two table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like to use its alias because field name is very long. It is composed of database_name + database ownder + table name + field name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, i want to use field via alias.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 May 2012 10:32:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298936#M27459</guid>
      <dc:creator>raphael_hernandesguimenes</dc:creator>
      <dc:date>2012-05-23T10:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Get field by alias</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298937#M27460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Raphael,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd advise against doing what you're trying.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The fact that the field name is long shouldn't matter to you (as a developer) since the end-user won't ever need to see the long field-name. They'll simply see the &lt;/SPAN&gt;&lt;STRONG&gt;value&lt;/STRONG&gt;&lt;SPAN&gt; of the long field in the infoWinow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A field-name is unique (ArcMap will throw an error if not) whereas aliases can be duplicated. The potential risk is that if you're trying to find a field by its alias you're not guaranteed to obtain the correct field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To rephrase this - why do you need to use the alias rather than the field-name in the infoWindow configuration? It seems like a lot of work for no real return.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 May 2012 10:40:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298937#M27460</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2012-05-23T10:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: Get field by alias</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298938#M27461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As I said, the field name is too large and it consists of database_name +&amp;nbsp; owner_database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Because this software will be installed in various locations, the name of the database may change and this can cause a big problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can't use a field name that contains the database_name&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you understand now?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please, see attachments&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you again.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 May 2012 11:07:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298938#M27461</guid>
      <dc:creator>raphael_hernandesguimenes</dc:creator>
      <dc:date>2012-05-23T11:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Get field by alias</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298939#M27462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If I understand you right, you want to display the alias field name for your data? As far as I know, you still need to use the actual name in the infotemplate, but there are a couple of ways to do it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If it's a featurelayer, you can get the alias from the fields property.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/featurelayer.htm#fields" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/featurelayer.htm#fields&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which is an array of fields&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/field.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi/field.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can then iterate the array, find the value you want and apply it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;something like&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var content = "";
for (var i=0, field; field = fields&lt;I&gt;; i++) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (field.alias == "TARGET") {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp = field.alias + ": ${" + field.name + "}";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; content += tmp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}
&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If not a featurelayer, you can use esri.request to get the field information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var handle = esri.request({
&amp;nbsp;&amp;nbsp;&amp;nbsp; url: "URLPATH",
&amp;nbsp;&amp;nbsp;&amp;nbsp; content: {"f" : "json"},
&amp;nbsp;&amp;nbsp;&amp;nbsp; handleAs: "json"
});

handle.then(function(result){
&amp;nbsp;&amp;nbsp;&amp;nbsp; var fields = result.fields;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // do your iteration to get template data here
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure if that's exactly the solution you are looking for, but I have a similar situtaion with a layer that has a join where I want to display the alias and not the long sde.dbo.blahblah name and this is similiar to how I do it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:21:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298939#M27462</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-12-11T14:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: Get field by alias</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298940#M27463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;there is the possibility of obtaining the field by "qualified name".?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In other words, without "sde.dbo" .&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want that the field name not contains "sde.dbo".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;do you know?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 May 2012 18:22:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-field-by-alias/m-p/298940#M27463</guid>
      <dc:creator>raphael_hernandesguimenes</dc:creator>
      <dc:date>2012-05-23T18:22:36Z</dc:date>
    </item>
  </channel>
</rss>

