Hi,
i am creating a custom module in Oscript. i need to add a folder in a ParentFolder when one perticular custom request handler was called. Could you please tell me what request handler i need to inherit to achive this task. Thanks in advance.
The creation of a custom folder is not really a job for a new RH. That is, you should be using the existing LL request handler and create a new WebNodeAction object. To understand why you can read the Execute method of the LL RH. If you have taken the Builder course already, you can refer to chapter 12, Adding A New Node Command. If you have not taken the Builder course I would suggest you do so before you go too much further.
You can also look at the Builder help, under Creating Custom Nodes > WebNodeCMD and WebNodeAction objects.
I hope this helps.
Howard Pell
Senior Technical Educator Liaison, Special Projects
Open Text Corporation
www.opentext.com
(519) 574-2248
From: eLink Entry: Content Server Development Forum [mailto:development@elinkkc.opentext.com] Sent: Monday, January 09, 2012 9:40 AMTo: eLink RecipientSubject: How to create a Folder using Oscript
How to create a Folder using Oscript
Posted by mbalasu1@visteon.com (Balasubramani, MuthuvelPrabhu) On 01-09-2012 09:28
[To post a comment, use the normal reply function]
Forum:
Content Server Development Forum
Content Server:
Knowledge Center
Hi Howard,
Thanks so much for your response. I need to create a Folder using DAPI.
I have tested create a document using DAPI. But when i try to do the same thing for creating folder. I am facing the issue. Node is created on DB but folder is not listed in the UI.
Following are the Code. please let me know if i need to do any changes in this.
I would echo Howard's advise that you take some oscript classes as the code looks like you are trying to create a folder but passing in the file data...or reusing some code that creates a file for your folderall subtypes have their implementation business rules and code.so a folder takes a parent to be in and a unique name I had a hard time understanding your code so I indented so it is a little more clearer and this works in mylivelink in the interest of time I used Dynamic which somebody is going to point out is bad practice. as a general rule use retval to route your code into the right program blocks.My guess is your code allocateda node but crashed on something else and you are not trapping what livelink is trying to tell you /* * This is the method subclasses implement to provide their functionality. * * @param {Dynamic} ctxIn * @param {Dynamic} ctxOut * @param {Record} request * * @return {Dynamic} Undefined */ function Dynamic Execute( \ Dynamic ctxIn, \ Dynamic ctxOut, \ Record request ) Object prgCtx = .PrgSession() echo("came") //very bad way of doing programming as you ares supposed to know the datatypes //i cannot help it because i am just trying to help Dynamic foldername,dSession,StorageFolder,NewFolderName,DestID,LLNode,retVal,storingFolder,nodeStatus assoc fileData destid=62495 dSession = prgCtx.Dsession().fSession foldername = DAPI.AllocNode( dSession ) StorageFolder = DAPI.GetNodeByID( dSession, 0, DestID ) LLNode = $LLIAPI.LLNodeSubsystem.GetItem ( $TypeFolder ) NewFolderName = "TestFolderCreation" retVal = $LLIAPI.NodeUtil.IsNameUnique( NewFolderName, StorageFolder ) //CODE NEEDS TO CHECK IF IT IS NOT OK AS WELL //BECAUSE WE NEED TO TRAP THE ERROR AS WELL OR YOU SHSOULD CHECK RETVAL AND IF RETVAL IS NOT OK //LIVELINK IS TRYING TO TELL YOU SOMETHING if ( retVal.OK ) StoringFolder = LLNode.NodeAlloc( StorageFolder, NewFolderName ) if ( StoringFolder.OK ) StoringFolder = StoringFolder.node fileData.comment = "Folder created via Script." // fileData.versionFile = fileName //fileData.fileName = $WebDocUtils.GetName( fileName ) //fileData.fileType = "html" //fileData.platform = DAPI.PLATFORM_WINDOWS //fileData.mimeType = "text/html" fileData.provider = "EXTSHARED" //not needed but that is not your problem else retVal.OK = False echo(retval.errmsg) //you would pass this to your weblingo so the user can know end else echo(retval.errmsg+" Trapping error on Node Uniqueness") end //AT THIS POINT IF OUR RETVAL IS OK WE CAN CREATE THE FOLDER if (retVal.OK) nodeStatus = LLnode.NodeCreate( StoringFolder,StorageFolder,fileData ) if ( !nodeStatus.OK ) retVal.OK = False echo(retval.errMsg) //you would pass this to your weblingo so the user can know else echo("folder created") end end return Undefined end