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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

How to customization advanced query

lliangjb
1-Newbie

How to customization advanced query

Similar to the windchill

Based on the advanced query function of attribute selection

1 ACCEPTED SOLUTION

Accepted Solutions
liliu
8-Gravel
(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
8-Gravel
(To:lliangjb)

Hi Mr. Liang,

I will do a sample for you soon.

Lily

lliangjb
1-Newbie
(To:liliu)

hi,Mrs Lily

     Myquery service Defined inside the thingtemplate?

liliu
8-Gravel
(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
8-Gravel
(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-Newbie
(To:liliu)

very detailed, thank you very much!

Top Tags