<?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 Valid DeriveFields expressions in ThingWorx Developers</title>
    <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Valid-DeriveFields-expressions/m-p/636959#M40699</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We are trying to fill in a thing name in the GetDesignTimePermission result infotable using the DeriveField snippet.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var params = {
   type: "Thing" /* STRING */,
   maxItems: 1000000 /* NUMBER */
};

var result1 = Resources["EntityServices"].GetEntityList(params);
var result2 = Things[result1.rows[0].name].GetDesignTimePermissions(); //This is only for a single entity for testing purposes

var params = {
  types: "STRING" /* STRING */,
  t: result2 /* INFOTABLE */,
  columns: "EntityName" /* STRING */,
  expressions: "result1.rows[0].name" /* STRING */
};

var result = Resources["InfoTableFunctions"].DeriveFields(params);&lt;/LI-CODE&gt;
&lt;P&gt;However we are having trouble finding a valid expression.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Error executing service GetDesignTimePermissionsforUser. Message :: Script evaluation error : ReferenceError: "result1" is not defined. (DSLCompiledExpressionProcessor#1) - See Script Error Log for more details.&lt;/LI-CODE&gt;
&lt;P&gt;What would be a valid expression to add the relevant thingname in a new column using DeriveFields?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;</description>
    <pubDate>Tue, 19 Nov 2019 14:45:52 GMT</pubDate>
    <dc:creator>BradC</dc:creator>
    <dc:date>2019-11-19T14:45:52Z</dc:date>
    <item>
      <title>Valid DeriveFields expressions</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Valid-DeriveFields-expressions/m-p/636959#M40699</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We are trying to fill in a thing name in the GetDesignTimePermission result infotable using the DeriveField snippet.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var params = {
   type: "Thing" /* STRING */,
   maxItems: 1000000 /* NUMBER */
};

var result1 = Resources["EntityServices"].GetEntityList(params);
var result2 = Things[result1.rows[0].name].GetDesignTimePermissions(); //This is only for a single entity for testing purposes

var params = {
  types: "STRING" /* STRING */,
  t: result2 /* INFOTABLE */,
  columns: "EntityName" /* STRING */,
  expressions: "result1.rows[0].name" /* STRING */
};

var result = Resources["InfoTableFunctions"].DeriveFields(params);&lt;/LI-CODE&gt;
&lt;P&gt;However we are having trouble finding a valid expression.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Error executing service GetDesignTimePermissionsforUser. Message :: Script evaluation error : ReferenceError: "result1" is not defined. (DSLCompiledExpressionProcessor#1) - See Script Error Log for more details.&lt;/LI-CODE&gt;
&lt;P&gt;What would be a valid expression to add the relevant thingname in a new column using DeriveFields?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 14:45:52 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Valid-DeriveFields-expressions/m-p/636959#M40699</guid>
      <dc:creator>BradC</dc:creator>
      <dc:date>2019-11-19T14:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Valid DeriveFields expressions</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Valid-DeriveFields-expressions/m-p/636974#M40701</link>
      <description>&lt;P&gt;Hi BradC,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think you will be able to add the Thing name through the use of DeriveFields(). This infoTable function is listed in a calculations category and only seems to work with mathematical expressions in my testing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="DeriveFields()" href="http://support.ptc.com/help/thingworx_hc/javadoc/com/thingworx/resources/queries/InfoTableFunctions.html#DeriveFields-com.thingworx.types.InfoTable-java.lang.String-java.lang.String-java.lang.String-" target="_blank" rel="noopener"&gt;DeriveFields()&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It may not be ideal but you can add a new column to your infoTable by using AddField() and writing logic to fill the cell value.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 15:52:58 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Valid-DeriveFields-expressions/m-p/636974#M40701</guid>
      <dc:creator>abrigode</dc:creator>
      <dc:date>2019-11-19T15:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Valid DeriveFields expressions</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Valid-DeriveFields-expressions/m-p/637413#M40780</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/254289"&gt;@abrigode&lt;/a&gt;&amp;nbsp;for confirming that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 06:49:04 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Valid-DeriveFields-expressions/m-p/637413#M40780</guid>
      <dc:creator>BradC</dc:creator>
      <dc:date>2019-11-21T06:49:04Z</dc:date>
    </item>
  </channel>
</rss>

