Using a Rule to set a *specific* repeating group's attribute

G

Greg S

Scenario: I have 2 repeating groups. One serves as a lookup table, the
other represents a table of new items.
ex.
lookups
products
@id
@name
@flagged (can be 0 or 1)

orders
order
orderItems
@qty
@productId
@special

Given that structure, I want a rule to fire so when a the @special attribute
is changed, I capture the @productId, then go back and find the matching
lookups/products/@id and set it to 1. Right now the generic rule can only
set all lookup/products/@flagged fields to 1. I tried manually editing the
xpath in the manifest.xsf to add a 'where clause' on the
xsf:assignmentAction targetField xpath as follows:
the generic rule:
../../lookups/products/@flagged
my change to manifest
../../lookups/products/[@id = current()/@productId]/@flagged

But I get an error when the rule fires that current() is an invalid
function.

As a test, I also used a hard-coded value
../../lookups/products/[@id = 7]/@flagged
and this worked fine.

Is there a solution to this?
 
G

Greg S

I've tried
current()/../@productId
current()/@productId
and
current()../@productId

and I always get the same error:

Unknown method.
[@id = -->current()<--

Too bad there's not a way to break into the assignmentAction with the
debugger to interrogate xpath.

thanks for trying!
 
G

Greg S

Discovered workaround:

Again, here's the original structure sample:

lookups (repeating)
products
@id
@name
@flagged (can be 0 or 1)

orders (repeating)
order
orderItems
@qty
@productId
@special

Then I added a new node in my data tree:
temp (not repeating)
@newlyFlaggedProductId


Now I have a rule on /orders/order/orderItems/@special
Condition: when set to true
Set field /temp/@newlyFlaggedProductId = @productId

Then I added an OnAfterChange event on /temp/@newlyFlaggedProductId
When it's trigged with eventObj.Action = "Insert"
I manually (via code) update the single /lookups/products item since I can
explicitly control the xpath to point to @id = whatEverIdarnWellPlease.

To summarize, a user can flag a field which traps an event, to trigger a
rule, which changes a field, which raises an event, which I can capture in
code, and then update the single little field.

"There was an old lady who swallowed a dog, to eat the cat, to catch the
mouse, to get the spider, to eat the fly....." or however that song when.

It works fine, but it seem rather inelegant.




Greg S said:
I've tried
current()/../@productId
current()/@productId
and
current()../@productId

and I always get the same error:

Unknown method.
[@id = -->current()<--

Too bad there's not a way to break into the assignmentAction with the
debugger to interrogate xpath.

thanks for trying!


Franck Dauché said:
Hi,

Have you try current()/../@productId?

Regards,

Franck Dauché


"Greg S" wrote:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top