Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An Action for Folders (count content) 2

Status
Not open for further replies.

SenadSe

Programmer
Dec 2, 2011
28
BA
I am trying tu buid a new action (WebNodeAction and WebNodeCmd).
What it should do is return an html which tells me:
how many folders are in the parent folder,
how many workflows...
how mamy documets
etc...

Now my question:
Are there predefined functions or parameters for this.
All i know there is the pChildCount parameter and the
"NumSubNodes(DAPINODE node )"
function which returns only the number of children.
 
you have to count the children yourself easiest would be a capi query

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
you can use the pChildCount value to get the number of direct child items of that node, for the other stuff I would use the CAPI select as APPNAIR suggests. If you want to pull the entire tree then I would probably looking at DTREEANCESTORS and DTREE to pull back the the information by subtype, if you only want direct children then you can look only at DTREE where the PARENTID is the folder id and then group by subtype.

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
For now i needed some fast results, so i did it with "NumSubNodes(DAPINODE node )". It counts only the first grade children (not the whole tree). CAPI seemed a bit complicated for me , but i will try it if i dont get it working the other way.

Thx for pointing directions, its great help.
 
if it is oracle then a variation of this query will be fast for you.
if you have a container with id 2000 all documents will be this

select count(*) from dtree where subtype=144 connect by prior dataid= parentid start with dataid=2000

with heavy hierarchies this query is inefficient so a better approach is using the dtreeancestors.Dtreeancestors build this relation so if you look at enterprise dataid in dtreeancestors it will give you all first level children.each first level children will have its corresponding children and so on.

also if there are volume objects such as projects,discussion etc you ahve to approach it a litlle differently

Let me know if this helps or I can post a capi snippet for you

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
Its MS SQL Server its the standard Database for CS10 i think.

what i tryed to do is this (in my html):

;CAPILOG logFile
;CAPIERR errHandler
;CAPICONNECT connect
;Dynamic execResult
;RecArray records
;Record rec
;Dynamic transResult

// Allocate a log and error object
;logFile = CAPI.AllocLog( 'c:\capi.log' )
;errHandler = CAPI.AllocErr()



// connect to the database
;connect = CAPI.AllocConnect( ; CAPI.CT_MSDBLIB,\ // or CT_DBLIB?
; 'TRAINGEN',; 'CS10',; 'livelink',; 'xxxxxxx',; logFile, ; errHandler, ; 0 )

// Return all values in myTable
;Dynamic result = CAPI.Exec( connect, "select * from DTreeAncestors" )


I get this messege:
A wrong argument type was specified was
and
E661979139 ("No Sql channel has been established. The required database drivers are not available.")

Im not sure about the host , user, pass, server info ... its t he standard info. I found some info where it sais DBhost is API100 or something, not sure if i shoudl use this .
 
I really would not put lots of OScript into your HMTL pages, I assume that this is the WebLingo layer you are talking about.

You should not need to create your own CONNECT object as one should be available already, so something like the following may work better :

Code:
RecArray vRes = CAPI.EXEC( prgCtx.fDBConnect.fConnection,"select * from DTreeAncestors")

Where
Code:
prgCtx
is the Program Context passed into your page, possibly in one of the other objects if not directly as prgCtx.

Also, avoid Dynamics, where possible, as they can be BAD as you don't know what type your variable is, it could be an integer, a RecArray, Assoc etc and certain methods react differently dependant on the datatype of the parameters used, see the OSCRIPT LANGUAGE REFERENCE -> OPERATORS section of the Builder online help for some examples.

I am also not sure why you are running this in your WebLingo, when your original question refered to a WebNode command creation ? is this HTML the output of the WebNodeCmd ? if so then I would recommend doing all the processing in the WebNodeAction and then just passing the results back up as per the module tutorial that comes with the Builder.

Your actual error refs to Livelink not being able to get a valid connection object using the database config etc you have provided, if you use the above method then you should not need to create your own connection and thus avoid this, although with some help it can be debugged to identify the problem(s) in the code.

If you do need to create a new DB connection have a look at
Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
Cool, your code is the way to go. (yes i dont need the connect object as you said).
I have prgCtx in the _SubclassExecute (as usual) so it works there.

I did it in html/weblingo only for testing. Now i can move on and code it on the right place.

Thx
 
And here is my solution. Maybe someone will find it usefull.

//Pull the request record elements needed for performing transactions
Dynamic prgCtx = request.prgctx
integer AnID = request.node.pID
RecArray contents = CAPI.EXEC( prgCtx.fDBConnect.fConnection,"select count(A.dataid) typeSum, D.subtype from DTreeAncestors A, Dtree D where A.ancestorid = :A1 and A.dataid <> A.ancestorid and A.dataid = D.dataid group by D.subtype ", AnID )

The result was exactly what i needed:
the subtypes and the amount of each subtype.
 
HI, i have a question on this thread again. I try to do the same what i did on folders, but no on Worksapces .

(If you read the first 3 posts on this thread it will be clear)

@greggriffith
you suggested:
"you can use the pChildCount value to get the number of direct child items of that node, for the other stuff I would use the CAPI select as APPNAIR suggests. If you want to pull the entire tree then I would probably looking at DTREEANCESTORS and DTREE to pull back the the information by subtype, if you only want direct children then you can look only at DTREE where the PARENTID is the folder id and then group by subtype. "


and now, i do need the whole three( for workspaces liike Enterprsie or Personal workspace (ParentID = -1 i would say).
So i cant use DTreeAncestor , what would be the best approach here?
 
perhaps if you look at objects of personal workspaces,project work spaces,discussions and many others you will understand the relation.

Parentid of -1 is the record of a workspace.Its ownerid is a neagtive number.

for e.g assume my id in livelink is 12345.all objects of this id will have the same ownerid or -12345.This will hold true for any volumesparentid f

so you could easily write a capi query to
select dataid,ownerid,parentid ,subtype from dtree where parentid=-1
From there isolate all records for subtype=141 or 142

then you can suitably do your hierarchy thru dtreeancestors test on small subsets until you have figured out the beautiful representation

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top