cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Adding Column to Infotable

ptc-6292144
3-Visitor

Adding Column to Infotable

I'm trying to add a column to an infotable I created using the DeriveFields snippet however I am receiving the error Wrapped java.lang.IllegalArgumentException: No enum constant com.thingworx.types.BaseTypes.org.mozilla.javascript.IdFunctionObject@1b2d8c9c Cause: No enum constant com.thingworx.types.BaseTypes.org.mozilla.javascript.IdFunctionObject@1b2d8c9c

I'm also not sure what to put under the expressions area.

My code is as follows.

var paramss = {

t: WasteTable /* INFOTABLE /,</div><div><span class="Apple-tab-span" style="white-space:pre">     </span>columns: "Week" / STRING /,</div><div><span class="Apple-tab-span" style="white-space:pre">     </span>types: Number / STRING */,

    expressions: '1'

};

// result: INFOTABLE

var result = Resources["InfoTableFunctions"].DeriveFields(paramss);

5 REPLIES 5
adam11
5-Regular Member
(To:ptc-6292144)

Hi Michael,

Assuming Number isn't a variable storing a string of base types, you will need to add quotation marks around Number.


Thanks,

Adam



adam11
5-Regular Member
(To:ptc-6292144)

To answer your second question:


DeriveFields is used to add additional fields to an info table based on an expression (ie. calculation). For example, if you wanted to add the values of two fields together, the value of expression would be:  myInfoTable.col1 + myInfoTable.col2


Is that what you're trying to do?


– Adam



Also please remember that BaseType declarations must be in all Capital letters.

So "NUMBER" vs. "Number"

Thank you both for the help. I'm simply just trying to add a column to an existing infotable. The column names will be conditional based on a separate query. Basically, I will have the code go through the results in an infotable from a query and add the columns named after each result in the query. Is there a better snippet to use to add columns to an infotable since the columns I am trying to add will not need to do any adding from existing columns?

AdamR
12-Amethyst
(To:ptc-6292144)

To add a field to any info table you can use...

infotable.AddField({name : "fieldname", baseType : "BASETYPENAME"});

Top Tags