Get correct value

L

Lu Prodesso

Hi all.
I have a infopath with a repeating group(1) with 2 fields(A and B), and I
have an other repeating group in which I must be able to select(drop
down-field C) out of repeating group (1-field A ) which I can manage. Now I
want value in field- D to automaticly fill with the value of the
corresponding value in field B in repaeting group 1. I want to do this in the
OnAfterChange of field C in C#-code.

Does anyone know any examples or ideas ?
 
A

Adam Harding

Lu

I dont think you need to use code to achieve this as you can do when field
is not blank rule to achieve stuff.

Am i understanding you correctly:

You have a repeating section with

Field A and Field B on dropdown lists

You have another Field C which is user definable and you want to use the
relation betwen A and B to define Field D automatically

You have to change the default value of FieldD to equal a secondary data
source field, then click filter and add filters to your hearts content setup
something like where FieldC relates to FieldB or something similar.

I hope this helps

Cheers Adam
 
S

S.Y.M. Wong-A-Ton

Like Adam said, you can do this without code, so you may want to consider this.

You never really specified where field D was located. Is it in the same
group as field C? Is field A unique in its group? This way it would be easier
to retrieve field B using a filter on repeating group 1.
 
S

S.Y.M. Wong-A-Ton

I don't have code at hand for this, but it shouldn't be difficult to
implement. Here is what you can do...

Look into the Source object on the event object (eventObj.Source) that is
being passed to the OnAfterChange event handler for field C. This will enable
you to get to the value of field C (which should be equal to field A) as well
as field C itself. Then you need to retrieve the parent of field C and use a
selectSingleNode on the parent to get to field D, which has the same parent
as field C. You can then use a filter in an XPath expression on group 1 to
get to field A. Once you have field A, navigate to its parent, and then use a
selectSingleNode on the parent to get to field B and its value. Note: It
should also be possible to use 1 XPath expression to get immediately to field
B and its value. Set the value of field D to the value of field B and you're
done.
 

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