Expand my Community achievements bar.

SOLVED

Change Document Names in Map of Documents

Avatar

Level 3

Hello,

I am taking the attachments from a completed task and putting them into a map of documents variable.  I was wondering if it is possible to change the names of the documents in the map?  I would like to be able to add an identifier to each document in the map.  Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 8

I think its a syntax thing.  I did a quick check and my processes don't use the @ symbol with lists and maps (only simple types)

LocationExpression
/process_data/MapKeysget-map-keys(/process_data/MapOfDocuments)

View solution in original post

8 Replies

Avatar

Former Community Member

You can use the setDocAttribute function.  The syntax is "setDocAttribute(com.adobe.idp.Document, String, String".  Check the Workbench Help for more detail.

Regards

Steve

Avatar

Level 3

Thanks for the quick response.  This looks like it should work to change the wsfilename, but how do I go through the map of documents and use the setDocAttribute on each document?

Avatar

Level 8

You'll have to touch each document in your map individually by writing a loop (or using java code in a script operation).  To get at a value in a Map use the syntax  /process_data/myMap[@id="myKey"]  where myMap is the name of your map variable and mykey is the name of the entry in the map object

Avatar

Level 3

Thanks for the information Hodmi.  I'm trying to access each section of the map but it does not seem to be working.  First, I'm getting the keys for the document map with the get-map-keys function.  Then I am trying to modify the first document in the map with this:

setDocAttribute(/process_data/MapOfDocuments[@id='/process_data/MapKeys[1]'], "wsfilename", "test.doc")

When I run this it does not change the first document name.  Any ideas why it isn't changing?

Avatar

Level 8

The problem is that you put the id in quotes - which no longer evaluates the statement, but treats it as a litteral.

To make it easier on my feeble brain (especially when debugging using record/playback) I break it down into multiple steps in the same set value

/process_data/@myTempID is a string

/process_data/@myTempDocis a Document

Location  
Expression
/process_data/@myTempID  /process_data/MapKeys[1]
/process_data/@myTempDoc /process_data/MapOfDocuments[@id=/process_data/@myTempID]
/process_data/MapOfDocuments[@id=/process_data/@myTempID]      setDocAttribute(/process_data/@myTempDoc, "wsfilename", "test.doc")

Avatar

Level 3

Thanks again for your help Hodmi.  I'm now having trouble getting the MapKeys into a list of strings though.  Right now I have the get-map-keys being assigned to a list of strings variable, but I am getting an error saying that it cannot be stored for action instance.  I'm getting this warning in the server log:

2009-07-27 11:08:18,729 WARN  [com.adobe.workflow.AWS] com.adobe.workflow.WorkflowRuntimeException: Invalid location: /process_data/@MapKeys cannot be stored for action instance: 2417

and then this error:

2009-07-27 11:08:18,729 ERROR [com.adobe.workflow.AWS] stalling action-instance: 2417 with message: Invalid location: /process_data/@MapKeys cannot be stored for action instance: 2417: com.adobe.workflow.WorkflowRuntimeException: Invalid location: /process_data/@MapKeys cannot be stored for action instance: 2417

For Location I have /process_data/@MapKeys and in Expression I have get-map-keys(/process_data/MapOfDocuments).  Any ideas why I would be getting this error?  Thanks again for any help.  I'm still learning a lot of this as I go.

Avatar

Correct answer by
Level 8

I think its a syntax thing.  I did a quick check and my processes don't use the @ symbol with lists and maps (only simple types)

LocationExpression
/process_data/MapKeysget-map-keys(/process_data/MapOfDocuments)

Avatar

Level 3

Perfect, thanks for all the help!