Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Dynamic SetValue

Avatar

Level 8
Level 8

Hi al,

I am creating a process in Workbench ES2 that takes a map (myMap) and an XML variable (myXML). The output is an xml-variable with some updated nodes (with values from the map.

The map looks like this:

<map>

  <entry>

    <string>form1/sub_Person/fld_Name</string>

    <string>Kim Christensen</string>

  </entry>

  <entry>

    <string>form1/sub_Person/fld_Address</string>

    <string>Rodeo Drive</string>

  </entry>

</map>

I need to have a "Set Value" service in a loop with one line that looks like this in the first iteration:

/process_data/myXML/myMap[key[1]] = myMap[id=key[1]]

This would update the "fld_Name" field in my XML to "Kim Christensen"

And the second iteration should update the field "fld_Address" to "Rodeo Drive".

I just cant make this work with a Set Value service. I have been experimenting with the object:

com.adobe.idp.workflow.dsc.type.SetValueMapping

but I can not really find any documentation or examples of how to use this.

Can you help out?

Thanks in advance

Sincerely

Kim Christensen

Dafolo A/S

6 Replies

Avatar

Level 10

I really think you'll have to do that in a script service or a custom component.

I don't believe you can access the key element with an index in the setValue.You'd have to use some java code.

Jasmin

Avatar

Level 8
Level 8

Hi again Jasmin,

I can build up the SetValueMapping object, that is no problem - but I don't really know how to execute it once I have built it. Can you help me here?

Otherwise I am not really sure how to approach this issue within the script service. Any pointers?

Sincerely Kim

Avatar

Level 10

Sorry, I don't know what a SetValueMapping object is.

You get the value of your xml and map in variables, using patExecContext.

See this blog for an example: http://eslifeline.wordpress.com/2008/06/25/clearing-the-contents-of-listmap/

This is also a link to the executeScript doc: http://livedocs.adobe.com/livecycle/es/wb_help/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Workben...

Then use them with any java code you want.

This is a java example that loops through a map that you could use in a Script service:

     HashMap map = new HashMap();

        map.put("index1","value1");

        map.put("index2","value2");

        Set keys = map.keySet();         // The set of keys in the map.

        Iterator keyIter = keys.iterator();

        System.out.println("The map contains the following associations:");

        while (keyIter.hasNext()) {

           Object key = keyIter.next();  // Get the next key.

           Object value = map.get(key);  // Get the value for that key.

           System.out.println( "   (" + key + "," + value + ")" );

        }

Jasmin

Avatar

Level 8
Level 8

Hi again Jasmin,

Thank you for your links and example.

The SetValueMapping object seems to be an object that holds a mapping for a Set Value call (location and expression) - so I can "almost" do what I want.

It is no problem getting the map-values into the execute-script-service, however I am not really sure how to get my XML variable in there.

Also I am not sure if I have to use some java code for XPath or I can somehow create my own SetValue object and execute it through the execute script service.

Once again thanks in advance.

Sincerely

Kim Christensen

Dafolo A/S

Avatar

Level 10

"It is no problem getting the map-values into the execute-script-service, however I am not really sure how to get my XML variable in there."

You just use the same technique.

DomDocument = patExecContext.getProcessDataValue(/process_data/xmlvar).

"Also I am not sure if I have to use some java code for XPath or I can somehow create my own SetValue object and execute it through the execute script service."

You'll have to use java code. The reason we need to use the script is because the setValue can't do it.

Jasmin