Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Content Management (Extended ECM)
API, SDK, REST and Web Services
Workflow Script - Attachments
Tod_Funk
Want to change the default owner for the worklow attachments folder to the admin. Plan is to get the nodeID of the wf attachment folder and then call the llnode.NodeRightUpdate script.How do I get the nodeID of the attachments folder from a workflow event script?Script:function Dynamic ChangeOwner( \ Object prgCtx, \ WAPIWORK work, \ Integer workID, \ Integer subWorkID, \ Integer taskID, \ Integer returnSubWorkID, \ Integer returnTaskID, \ Dynamic extraData = Undefined ) Dynamic retVal Dynamic userID DAPINODE node Object llnode Dynamic perms Dynamic type Dynamic nodeID type = 1 /* type is user */userID = 1000 /* admin ID */ node = DAPI.GetNodeByID( prgCtx.fDSession.fSession, DAPI.BY_DATAID, nodeID )llnode = $LLIApi.LLNodeSubsystem.GetItem( node.pSubType ) perms = node.pUserPerm retVal = llnode.NodeRightUpdate( node,type,UserID, perms )return( retVal )endThanks
Find more posts tagged with
Comments
Krishnankutty_Nair
This is the location of OpenText CodeWFMain->WFRoot->CallBackEventScripts->GeneralCallBackScripts->SaveToOrigThis is our way of doing it**************************************Function Dynamic _GetAttachmentData( \ Object prgCtx, \ WAPIWORK work ) dynamic wfWorkPackages dynamic package DAPISession dSession = prgCtx.DSession().fSession DAPINode attachmentData // Get the work from the database and load the packages into wfWorkPackages wfWorkPackages = $WFMAIN.WAPIPkg.LoadWorkData( prgCtx, work ) // Go through the packages and find the attachment package (subtype = 1) for package in wfWorkPackages if package.Type == 1 and package.SubType == 1 attachmentData = DAPI.ListSubNodes( DAPI.GetNodeById(dSession, 0, package.USERDATA) )[ 1 ] break end end Return( attachmentData )end***************************************
Donna Nalls
Hello,Your script looks fine, but i would like to offer a couple of suggestions:1) use an object reference to retrieve the workflow DAPI Attachments object.....this will prevent having to hard-code the type and subtype --- we never know when OT development might change something like this and then you are stuck troubleshooting an fixing code.2) same for hard-coding user type - best to use the UAPI constant.....UAPI.USER -- instead of type=1: type=UAPI.USER3) depending on where you are going to run this script, you may also have to consider that the user by whom the script is processing may not have permissions to change the permissions...in which case, i revert to a sql stmt and update the record in the dtree directly...not the recommended approach, but sometimes - "ya gotta do, what ya gotta do!" ;o)attached is a utility script that i use often for retrieving the wflow attachments folder - returns an assoc with the following elements:boolean ok - success or not string errMsg - error message (if applicable)integer folderid - the attachment folder dataiddapinode foldernode - the attachment folder dapinodeBest,Donna
Tod_Funk
Thank you very much, Nair !It worked. I am a new Livelink developer, so I hope to use your expertise in the future.
Krishnankutty_Nair
I always steal donna's code from OT for workflow step so she is the guru.Look into her better suggestions also