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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

get all items and subItems of a Group using BrowseItems

AN_9685270
5-Regular Member

get all items and subItems of a Group using BrowseItems

Hello evryone, 

 

I want to browse all items and subItems of a group but when I use BrowseItems services the parameter filter doesn't work well.

 

so When I write that : 

/ result: INFOTABLE dataShape: "IndustrialItems"
var result = Things["TestIndConnEnergyRum"].BrowseItems({
filter: "*" /* STRING */,
path: "RUM_P1_MAG_VENTE" /* STRING */
});

I get no result but when i Specify some channels i get data 

 

thanks in advance

 

1 ACCEPTED SOLUTION

Accepted Solutions
AN_9685270
5-Regular Member
(To:slangley)

Thank you @slangley for your reactivity, 

 

I found a solution using just some for loops, to browse all tags from an industrial connection, using just 2 services ; browseGroups and BrowseItems, 

please find this attached my solution 

 

// this service is for browsing all tags of an industrial connection 

//level 1 : Groups
//level 2 : SubGroups
//Level 3 : items or Tags 

var IndustrialConnectionThingName ="YourIndustrialConnectionThingName";
//get Groups
var Groups = Things[IndustrialConnectionThingName].BrowseGroups({
    filter: undefined /* STRING */,
    path: undefined /* STRING */
});
var resGroups = [];
for (var x=0x <  Groups.rows.lengthx++){
    var row = Groups.rows[x];
    var hasAnySubGroups = row.HasAnySubGroups;
    var IsSystemGroup = row.IsSystemGroup;
    var HasNonSystemSubGroups = row.HasNonSystemSubGroups;
    if(!IsSystemGroup &&HasNonSystemSubGroups && hasAnySubGroups){
        var groupFullPath = row.FullPath ;
        resGroups.push(groupFullPath);
       }
}
//Get SubGroups
var resSubGroups = [];
for (var i=0i < resGroups.lengthi++) {
    var resGroupsRow = resGroups[i];
    var SubGroups = Things[IndustrialConnectionThingName].BrowseGroups({
    filter: undefined /* STRING */,
    path: resGroupsRow /* STRING */
    });
    
    for (var j=0j < SubGroups.rows.lengthj++) {
        var SubGroupsRow = SubGroups.rows[j];
        var hasAnySubGroups = SubGroupsRow.HasAnySubGroups;
        var IsSystemGroup = SubGroupsRow.IsSystemGroup;
        var HasNonSystemSubGroups = SubGroupsRow.HasNonSystemSubGroups;
        if(!IsSystemGroup ){
            var SubGroupFullPath = SubGroupsRow.FullPath ;
            resSubGroups.push(SubGroupFullPath);
       }
    }
    
}

// Get Items === Tags
//var resItems  = [];

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(IndustrialItems)
var resItems = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
    infoTableName : "InfoTable",
    dataShapeName : "IndustrialItems"
});



// iterate over resSubGroups to get items
for (var p=0p < resSubGroups.lengthp++) {
    var resSubGroupsRow = resSubGroups[p];
        // result: INFOTABLE dataShape: "IndustrialItems"
    var items = Things[IndustrialConnectionThingName].BrowseItems({
        filter: undefined /* STRING */,
        path: resSubGroupsRow /* STRING */
    });
    
    //iterate over items to find tags and push them in resItems 

    for (var k=0k < items.rows.length;k++) {
        var itemsRow = items.rows[k];
        //var TagName = itemsRow.Source ;
        //resItems.push(TagName);
        resItems.AddRow(itemsRow);
    }
    
}
//infotable : datashape : industrialitems 
result = resItems;

 

 

View solution in original post

4 REPLIES 4
slangley
23-Emerald II
(To:AN_9685270)

Hi @AN_9685270.

 

We found an internal case on this issue.  I have requested a status and will post additional information here as it becomes available.

 

Regards.

 

--Sharon

slangley
23-Emerald II
(To:slangley)

Hi @AN_9685270.

 

After reviewing with R&D, we're not sure this is the same issue that was previously reported.  You indicated in your post "I get no result but when i Specify some channels i get data."

 

Per the information in the Help Center, providing the channel is a requirement.  Please refer to this page and let me know if I'm misunderstanding something.

 

Regards.

 

--Sharon

slangley
23-Emerald II
(To:slangley)

Hi @AN_9685270.

 

Good job!  Since you found a solution, please mark your last response as the Accepted Solution for the benefit of others with the same issue.

 

Regards.

 

--Sharon

AN_9685270
5-Regular Member
(To:slangley)

Thank you @slangley for your reactivity, 

 

I found a solution using just some for loops, to browse all tags from an industrial connection, using just 2 services ; browseGroups and BrowseItems, 

please find this attached my solution 

 

// this service is for browsing all tags of an industrial connection 

//level 1 : Groups
//level 2 : SubGroups
//Level 3 : items or Tags 

var IndustrialConnectionThingName ="YourIndustrialConnectionThingName";
//get Groups
var Groups = Things[IndustrialConnectionThingName].BrowseGroups({
    filter: undefined /* STRING */,
    path: undefined /* STRING */
});
var resGroups = [];
for (var x=0x <  Groups.rows.lengthx++){
    var row = Groups.rows[x];
    var hasAnySubGroups = row.HasAnySubGroups;
    var IsSystemGroup = row.IsSystemGroup;
    var HasNonSystemSubGroups = row.HasNonSystemSubGroups;
    if(!IsSystemGroup &&HasNonSystemSubGroups && hasAnySubGroups){
        var groupFullPath = row.FullPath ;
        resGroups.push(groupFullPath);
       }
}
//Get SubGroups
var resSubGroups = [];
for (var i=0i < resGroups.lengthi++) {
    var resGroupsRow = resGroups[i];
    var SubGroups = Things[IndustrialConnectionThingName].BrowseGroups({
    filter: undefined /* STRING */,
    path: resGroupsRow /* STRING */
    });
    
    for (var j=0j < SubGroups.rows.lengthj++) {
        var SubGroupsRow = SubGroups.rows[j];
        var hasAnySubGroups = SubGroupsRow.HasAnySubGroups;
        var IsSystemGroup = SubGroupsRow.IsSystemGroup;
        var HasNonSystemSubGroups = SubGroupsRow.HasNonSystemSubGroups;
        if(!IsSystemGroup ){
            var SubGroupFullPath = SubGroupsRow.FullPath ;
            resSubGroups.push(SubGroupFullPath);
       }
    }
    
}

// Get Items === Tags
//var resItems  = [];

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(IndustrialItems)
var resItems = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
    infoTableName : "InfoTable",
    dataShapeName : "IndustrialItems"
});



// iterate over resSubGroups to get items
for (var p=0p < resSubGroups.lengthp++) {
    var resSubGroupsRow = resSubGroups[p];
        // result: INFOTABLE dataShape: "IndustrialItems"
    var items = Things[IndustrialConnectionThingName].BrowseItems({
        filter: undefined /* STRING */,
        path: resSubGroupsRow /* STRING */
    });
    
    //iterate over items to find tags and push them in resItems 

    for (var k=0k < items.rows.length;k++) {
        var itemsRow = items.rows[k];
        //var TagName = itemsRow.Source ;
        //resItems.push(TagName);
        resItems.AddRow(itemsRow);
    }
    
}
//infotable : datashape : industrialitems 
result = resItems;

 

 

Top Tags