Database.Find not working in publisher

Translate this pagebookmark or share this page
Rick's picture

Posted: 2012-08-09
508 views | 1 comments | category: ARIS Support

0
show all articles

I have this function:

this.TestReport = function(oDatabase){
            
            var oXmlWriter = Context.createXMLOutputObject("products.xml", "products"); 
            
            var models = oDatabase.Find(Constants.SEARCH_GROUP);
            
            var oProducts = [];

                       var oProductData = {    
                                                isnull:models.length
                                          }
                        oProducts.push(oProductData);
                        var oProductElem = oCXML.AddElement(oProductData,oXmlWriter.getRootElement(),"product", oXmlWriter);
            
                oXmlWriter.WriteReport();
            
        }

(oCXML is a custom object that contains a function for adding elements)

When I run this, the output reports the length of the 'models' variable as being 0 (zero). Indicating that it has not found any groups in the database. I assure you, there are groups in the database :).

This works fine in Aris Architect. What am I missing?

Thanks,

Rick Beddoe
Cargill Aris Technical Analyst
Minneapolis, MN, USA

Comments
Rick's picture

Well, I just could not get Database.Find to work, so here is my workaround:

var rootGroup = oDatabase.RootGroup();
var oChildren = rootGroup.Childs(true);
var group = JSLINQ(oChildren)
           .Where(function(grp){return grp.Name(oLocale) == "Organization Hierarchy";})
           .ToArray()[0];           
                 

As you can see, I am using JSLINQ to quickly find the desired group from all 'Childs' groups.

If anyone has a better idea, please feel free to share.

Thanks,

Rick Beddoe
Cargill Aris Technical Analyst
Minneapolis, MN, USA