Status: Open
Status: Answered
Status: Closed
Status: Duplicate

Uploading a document to Attachments folder using CS REST API

0
Posted Jul 05 by Hugh Ferguson.

Hi,
I've been working on a REST extension for Workflow. Almost everything works except uploading attachments. I was going to use the nodes API to manage that, but I run into problems on the CSNode.ValidateParent(). Because attachments folders (subtype 154) are not defined, it always fails on the ValidateParent() on the Create NodeAction (all in Oscript). Here is the block of code that is failing:

        if ( self.node_ref.GetType() in csNode.GetChildRelationships() ) 
            parentNode = csNode.GetDapiNode()           
        else            
            //
            // See if there is an associated volume (brute force method for greater compatibility).
            //
            checkVal = $CSNODE.NodeSubsystem.GetNode( self.node_ref.GetProgramSession(), -parentId )

            if ( checkVal.ok == TRUE )

                csNode = checkVal.csNode

                garbageCollection = List.SetAdd( garbageCollection, $KERNEL.FrameWrapper.New( csNode ) )

                if ( self.node_ref.GetType() in csNode.GetChildRelationships() )

                    parentNode = csNode.GetDapiNode()

                else
                    self.SetError( Str.Format( [CSNODE_ERRMSG.CouldNotCreateItem1InContainer2], self.node_ref.GetTypeName(), csNode.GetTypeName() ) )
                end

            else
                self.SetError( Str.Format( [CSNODE_ERRMSG.CouldNotCreateItem1InContainer2], self.node_ref.GetTypeName(), csNode.GetTypeName() ) )
            end

        end

In particular, the CSNode for the parent (in this case, a generic CS Node for the attachments folder) has no child_relationships set up, but also, the second part where it attempts to locate the volume using the -parentID will fail because the volumeID for an attachments folder is not -id but something else (probably the volume ID of the map holder temporary object that gets created for a workflow prior to initialization).

The way around this would be to orphan off a CS Node to represent a WF attachments folder. If I do that, where does the child_relationships list get built? I saw it being done in AppendRelationships which is supposedly called from BuildNode but I'm not sure where that gets called. I will eventually find it, but if there is a general guideline to orpahning CS nodes and making sure that they are properly set up, I'd love to hear.<br/>
Thanks in advance<br/>
-Hugh Ferguson

2 Answers

0
BEST ANSWER: As chosen by the author.

My solution to this was to orphan the Folder CSNode and set it up with the appropriate name and subtype. Then with a rebuild of the ospace, it autoregisters, and voila, I have a CSNode for Attachments folders that will work with the new API.<br/>
-Hugh


0
BEST ANSWER: As chosen by the author.

I have same issue, is there any solution how to solve it in current API ?


 You have subscribed and will receive email notifications of updates to this topic. To unsubscribe, uncheck the checkbox.

Statistics

Related categories

Your answer

To leave an answer, please sign in.