Posts tagged XPath

Stopping Duplicate Attachments in Workspace


When using the attachments feature on the User service, you may have encountered a situation where attachments are being duplicated at each step of the process. This will happen whether you reference the “list of document” variable itself or the XPath expression of the variable.

The way to get around this issue is to reference the XPath expression of the variable and append [1] to it.


In Workbench, navigate to the Attachments tab of the User service.
In the Output Attachments section, make sure that the dropdown is set to XPath expression.
Select your variable of type list of document and append [1] to it.
It should now appear as /process_data/myAttachments[1].

Attachments tab on the User serviceAttachments tab on the User service

Make sure you use this same notation (/process_data/myAttachments[1]) on each User service step.

——-
Original article at http://blogs.adobe.com/ADEP/2011/08/stopping-duplicate-attachments-in-workspace.html.

Introducing LC Keywords-Logical Operators– and,or

I was experimenting with xpath expression and found that the ‘and’ and ‘or’ works perfectly as the logical operators.
I’m perosnally so happy to see them working. In few cases it was too hard to configure the conditional routes with just OR/AND joint.

I’ve attached an example to demonstrate a simple usage of ‘and’-’or’ logical operators. This is the condition that I’ve put in the example.

(normalize-space(/process_data/@Input_Value1)=’555′ or normalize-space(/process_data/@Input_Value1)=’666′) and (normalize-space(/process_data/@Input_Value2)=’777′)

I believe that this is going to make workflow design so much cleaner. Instead of nested conditional routes and 4-5 decision points or set value steps we would be able to do lot more things in few steps now.

I think this is an XPath Explorer feature so is not limited to just route conditions. All of the places where XPath expression is evaluated should be able use these.

Hope this helps to you too!!!

—-
Original article at http://blog.pandyaparth.com/2009/07/introducing-lc-keywords-logical-operators-andor/.

Conditional set value using XPath


In my quest to use XPath functions & expressions more efficiently in LiveCycle I managed to achieve ‘conditional set value’ yesterday.

Example scenarios:

  • Add some text to email body if some condition is true/false.
  • Add some text into T&Cs if certain product is selected.
  • In a generic/single Email or Set Value step you need to construct a big block of text. eg. Offer letter with certain paragraphs based on few conditions.

Approach 1: The usual way (or one of the usual ways):

An orchestration in Workbench with few setValue steps and few conditional routes to add/append the desired text to existing text.

And these steps need to be in certain order.

Approach 2: The XPath trick

I used substring() and number() function with pure XPath expression to construct conditional set value. See the usage below.

Example:

Consider a requirement in which you wish to send an email with few extra lines added to it if product A is ordered. And if contract term is 12 months then we need to add another T&C statement in the email body.

Let’s implement that with both approaches…

Approach 1: Few set value step and routing conditions to set process variables that get used in email body.

Process Diagram:
Set Value - Route condition approachSet Value – Route condition approach
Email body:

Dear Provisioning Team,

Please send the below details to John.

System:{$ /process_data/@System $}
Agent Name:{$ /process_data/@Agentname $}
Product ordered: {$ /process_data/@Product $}

{$ /process_data/@ProductAConfigurationDetails $}

Terms and Conditions:
blah blah blah from Legal
adf
adf
{$ /process_data/@TCFor12MonthsContract$}
blah
blah

regards,
BOH Team

Approach 2: Conditional set value with XPath

Process diagram:

Set Value XPath approach

Email Body

Dear Provisioning Team,

Please send the below details to John.

System:{$ /process_data/@System $}
Agent Name:{$ /process_data/@Agentname $}
Product ordered: {$ /process_data/@Product $}

{$ substring(‘This is where the actual text gets put about the product configuration’,
50000000 * (number(/process_data/@Product !=’Product A’))
) $}

Terms and Conditions:
blah blah blah from Legal
adf
adf
{$ substring(’12 Months T&C content is written here or can be xpath expression’,
50000000 * (number(/process_data/@ContractLength !=’12′))
) $}

blah
blah

regards,
BOH Team

Explanation:

  • The above expression marked in blue puts the text in email body if the condition at the end of it fulfills.
  • By moving this logic into the email step itself I could clean up the process design significantly. I believe that LC is too good to do data transformation but common…few set value and few conditional routes for a simple text insertion?? I reckon the XPath trick gives much more cleaner approach to solve this.
  • First thing to notice in the expression is the use of a large number 50000000 . This is used to return blank substring value if the expression is false. Please adjust if your input text can be larger than this.
  • Second thing to notice is the use of comparison operator. I wanted to have 0 (zero) value for substring start value if condition is true. Boolean true is 1 so I’m using opposite operator. Eg. if(product=”Product A”) is represented as product!=”Product A”

As this is an XPath based expression we can use it in any LC component. I tried implementing if-else clause as well but that didn’t turn out well.

If you managed to read through this much then I’m sure you would love to see the undocumented ‘and’ ‘or’ keyword usage in XPath expression. I found that while experimenting and it’s an instant hit among few of my fellow LC users. It can be found here..

Let me know if you find this useful!!!!

—-
Original article at http://blog.pandyaparth.com/2009/11/conditional-set-value-using-xpath/.

Go to Top