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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

How to customization advanced query

lliangjb
1-Visitor

How to customization advanced query

Similar to the windchill

Based on the advanced query function of attribute selection

ACCEPTED SOLUTION

Accepted Solutions
liliu
12-Amethyst
(To:lliangjb)

Hi Mr. Liang,

Here is my sample code:

var query1 =
{
    "filters": {
        "type": "GT",
        "fieldName": "num",
        "value": "12"}
};
var values = me.CreateValues();
values.num = num; //NUMBER
values.name = name; //STRING [Primary Key]
var params = {
maxItems: 500 /* NUMBER */,
values: values /* INFOTABLE*/,
query: query1 /* QUERY */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
};
var result = me.QueryDataTableEntries(params);

For detail query infomation, please check here PTC.

And the values is what exectly you want to filter your datatable.

If you are using a InfoTable, and cannot use API QueryDataTableEntities, please follow below code:

var params = {
maxItems: 500 /* NUMBER */
};
var myInfo = me.GetDataTableEntries(params);
var query1 =
{
    "filters": {
        "type": "and",
        "filters":[
            {
                "type":"EQ",
                "fieldName":"num",
                "value":num
            },
            {
                "type":"EQ",
                "fieldName":"name",
                "value":name
            }
        ]
    }  
};
var params = {
t: myInfo /* INFOTABLE */,
query: query1 /* QUERY */
};

// result: INFOTABLE
var result = Resources["InfoTableFunctions"].Query(params);

And the binding is like below screenshot:

Lily

View solution in original post

5 REPLIES 5
liliu
12-Amethyst
(To:lliangjb)

Hi Mr. Liang,

I will do a sample for you soon.

Lily

lliangjb
1-Visitor
(To:liliu)

hi,Mrs Lily

     Myquery service Defined inside the thingtemplate?

liliu
12-Amethyst
(To:lliangjb)

Hi Mr. Liang,

Just follow below sample:

 

var query1 =
{
    "filters": {
        "type": "and",
        "filters":[
            {
                "type":"EQ",
                "fieldName":"num",
                "value":num
            },
            {
                "type":"EQ",
                "fieldName":"name",
                "value":name
            }
        ]
    }  
};

 

var params = {

 

oldestFirst: undefined /* BOOLEAN */,

 

maxItems: undefined /* NUMBER */,

 

endDate: undefined /* DATETIME */,

 

query: query1 /* QUERY */,

 

startDate: undefined /* DATETIME */

 

};

 

// result: INFOTABLE

 

var result = Things["ThingName"].QueryPropertyHistory(params);

 

Any concern, just feel free to let me know.

liliu
12-Amethyst
(To:lliangjb)

Hi Mr. Liang,

Here is my sample code:

var query1 =
{
    "filters": {
        "type": "GT",
        "fieldName": "num",
        "value": "12"}
};
var values = me.CreateValues();
values.num = num; //NUMBER
values.name = name; //STRING [Primary Key]
var params = {
maxItems: 500 /* NUMBER */,
values: values /* INFOTABLE*/,
query: query1 /* QUERY */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
};
var result = me.QueryDataTableEntries(params);

For detail query infomation, please check here PTC.

And the values is what exectly you want to filter your datatable.

If you are using a InfoTable, and cannot use API QueryDataTableEntities, please follow below code:

var params = {
maxItems: 500 /* NUMBER */
};
var myInfo = me.GetDataTableEntries(params);
var query1 =
{
    "filters": {
        "type": "and",
        "filters":[
            {
                "type":"EQ",
                "fieldName":"num",
                "value":num
            },
            {
                "type":"EQ",
                "fieldName":"name",
                "value":name
            }
        ]
    }  
};
var params = {
t: myInfo /* INFOTABLE */,
query: query1 /* QUERY */
};

// result: INFOTABLE
var result = Resources["InfoTableFunctions"].Query(params);

And the binding is like below screenshot:

Lily

lliangjb
1-Visitor
(To:liliu)

very detailed, thank you very much!

Announcements


Top Tags