Hi,
here you can see a function that I use with success for create a folder, I need to associate a category to this folder, how can I do it?
Thank you in advance.
// very simple sample script to create a new folder
// dnalls 02/27/2007
function Integer CreateNewFolder(Dynamic prgCtx, Integer parentId, String folderName="demo folder")
Object llNode = $LLIAPI.LLNodeSubsystem.GetItem($TypeFolder) // retrieve the folder llNode object
DapiNode parentNode // parent folder dapinode
DapiNode folderNode // new folder dapinode
Assoc createInfo = Assoc.CreateAssoc() // create folder info
Assoc retVal = Assoc.CreateAssoc() // set default return values
retVal.ok = true
retVal.errMsg = ""
Boolean debug = False
Integer iRet = -1
// read log level from config file
String isDebug = [CUSTWF_CONFIG.ChangeAttributeLogLevel]
if IsDefined( isDebug ) && isDebug == 'True'
debug = True
end
if ( debug )
Echo ("custwf:CreateNewFolder->Avvio CreateNewFolder")
end
// don't leave home with a parent container id
if (parentId >0)
parentNode = DAPI.GetNodeById(prgCtx.dSession().fSession, DAPI.BY_DATAID, parentId)
// if valid parent, create child folder
if !isError(parentNode)
// Check to see if a workflow report already exists.
retVal = $LLIAPI.NodeUtil.IsNameUnique( folderName, parentNode )
// if the workflow report doesn't already exist then add it.
if ( retVal.OK )
// allocate a folder node using llNode method
retVal = llNode.NodeAlloc(parentNode, folderName)
if (retVal.ok)
retVal = llNode.NodeCreate(retVal.Node, parentNode, createInfo)
// update permissions/acls
if (retVal.ok)
// have a look in the folder llNode object
// for methods that start with "NodeRight" --
// these are the methods that update the acls....
// determine which are most appropriate for your needs
iRet = retVal.Node.pID
if ( debug )
Echo ("custwf:CreateNewFolder->ok retVal.Node.pID:",retVal.Node.pID)
end
end
else
retVal.ok = false
retVal.errMsg = "Unable to Allocate a Node"
if ( debug )
Echo ("custwf:CreateNewFolder->Unable to Allocate a Node")
end
end
else
//Il noto già esiste
if ( debug )
Echo ("custwf:CreateNewFolder->Il noto già esiste")
end
folderNode = DAPI.GetNode(folderName, parentNode)
if !isError(folderNode)
//Il noto già esiste
iRet = folderNode.pID
if ( debug )
Echo ("custwf:CreateNewFolder->NodoID:",iRet)
end
else
if ( debug )
Echo ("custwf:CreateNewFolder->Individuazione nodo fallita")
end
end
end
else
retVal.ok = false
retVal.errMsg = "Unable to Retrieve DapiNode"
if ( debug )
Echo ("custwf:CreateNewFolder->Unable to Retrieve DapiNode")
end
end
else
retVal.ok = false
retVal.errMsg = "Invalid ParentId"
if ( debug )
Echo ("custwf:CreateNewFolder->Invalid ParentId")
end
end
return (iRet)
end