Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / April 2006

Tip: Looking for answers? Try searching our database.

Default value in field contained in repeating section

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paulo - 22 Apr 2006 17:25 GMT
Hello everybody,

As the subject says, I have a repeating section with several fields. The
users are able to add/remove them. Whenever they add one, I want a field in
the added section to get a random value.

At first I wanted to use the default value feature of the field. But I am
not able to specify my own function...

So I started to look at the onvalidate event, but the site method returns a
read-only object so that I'm not able to change it....

I am sure this is pretty easy, but could one help me?

Thanks, Paulo
S.Y.M. Wong-A-Ton - 23 Apr 2006 12:16 GMT
Did you also try the OnAfterChange event? The DOM is writable in the
OnAfterChnage.
---
S.Y.M. Wong-A-Ton

> Hello everybody,
>
[quoted text clipped - 11 lines]
>
> Thanks, Paulo
Paulo - 23 Apr 2006 14:21 GMT
Hello,

Thanks  for your response.
Well, then there is something I am missing.
Onvalidate, onafterchange, onbeforechange all have DataDOMEvent object as a
parameter. Thus Object has several properties including one that is the site
property which enables me to know which of the repeating node generated the
event. I want then to change that particular node's value. But the site
method is readonly. If I use the XDocument property of the DataDOMEvent, how
will I be able to know which of my repeating fields just generated the event?

What am I missing?
Thanks

> Did you also try the OnAfterChange event? The DOM is writable in the
> OnAfterChnage.
[quoted text clipped - 16 lines]
> >
> > Thanks, Paulo
S.Y.M. Wong-A-Ton - 23 Apr 2006 16:18 GMT
Oi Paulo,

Both Site and Source are read-only properties, but you can use their
properties and methods to get to nodes in the DOM and change values as
demonstrated in the code accompanying this article:
http://enterprise-solutions.swits.net/infopath/adding-time-calculating-differenc
es.htm

and this article:
http://enterprise-solutions.swits.net/infopath/retrieve-field-value-same-row-rep
eating-table.htm

---
S.Y.M. Wong-A-Ton

> Hello,
>
[quoted text clipped - 30 lines]
> > >
> > > Thanks, Paulo
Paulo - 24 Apr 2006 21:41 GMT
Hello,

Again, thanks for your help. I had a look at your code and I was pretty
convinced it would work but it didn't..
So here is what I did:
<Section>
<SectionID/>
 <Question>
  <QuestionID/>
  </Question>
</Section>
I added an Onafterchange event to QuestioID for example.
BTW: Section and Question are repeatable sections..
Question is a whole integer
The code looks like this:

function msoxd_my_QuestionID(eventObj) {
// First I tried another approach
eventObj.Site.removeAttribute("xsi:nil");
//I was hoping this is the right object since when I call
eventObj.Site.nodeName I get the right element name
eventObj.Site.text = 1111;
}

It tells me:
Text is not allowed in the context of element .... acording to DTD/Schema...

ok so I tried another method.. the one described on your pages which I think
is quite the same.
I think I extracted was is relevant for what I wanted to do

function msoxd_my_QuestionID(eventObj) {
var xmlNil = eventObj.Site.ownerDocument.createNode(2,"xsi:nil",
"http://www.w3.org/2001/XMLSchema-instance");

xmlNil = "true";
eventObj.Site.text='';
eventObj.Site.setAttribute(xmlNil);
// change the value here...
}

When I do this I can into a recursion loop...

I still am not able to do it :(
Paulo
S.Y.M. Wong-A-Ton - 25 Apr 2006 11:10 GMT
I'm not sure what you're trying to do, Paulo. I tried your first method and
it worked fine for me. I put a repeating table in a repeating section and
tried to programmatically write to a field (Whole Number) in the repeating
table (QuestionID) in your case, and it worked. The code that I added to the
OnAfterChange of the field was:

if (eventObj.Site != eventObj.Parent)
{
 eventObj.Site.removeAttribute("xsi:nil");
 eventObj.Site.text = 2;
}

How did you set up your form? It sounds like you are trying to do something
that is not allowed by the schema of the form.

You may want to read this article too:
http://msdn.microsoft.com/library/en-us/ipsdk/html/ipsdkHandleDoubleNotification
s_HV01083591.asp?frame=true
.
---
S.Y.M. Wong-A-Ton

> Hello,
>
[quoted text clipped - 41 lines]
> I still am not able to do it :(
> Paulo
Paulo - 25 Apr 2006 16:49 GMT
Hello,

> I'm not sure what you're trying to do, Paulo. I tried your first method and
> it worked fine for me. I put a repeating table in a repeating section and
> tried to programmatically write to a field (Whole Number) in the repeating
> table (QuestionID) in your case, and it worked. The code that I added to the
> OnAfterChange of the field was:

And you attached this to the QuestionID field...right?

> if (eventObj.Site != eventObj.Parent)
> {
[quoted text clipped - 4 lines]
> How did you set up your form? It sounds like you are trying to do something
> that is not allowed by the schema of the form.

Euh, what do you mean?:).
I added the fields one after the other...
Hm how do I debug this Schema violation?

Paulo
Paulo - 25 Apr 2006 18:32 GMT
Hello again,

I think I got it!
Stupid!
For my tests I always perfomed a Preview Form.....
But when I close it and fill it out, then it works..... :)

I need additional tests but I think that's it!
Thanks for your help!!!
Paulo

> I'm not sure what you're trying to do, Paulo. I tried your first method and
> it worked fine for me. I put a repeating table in a repeating section and
[quoted text clipped - 61 lines]
> > I still am not able to do it :(
> > Paulo
S.Y.M. Wong-A-Ton - 25 Apr 2006 19:13 GMT
Glad you finally got it to work!
---
S.Y.M. Wong-A-Ton

> Hello again,
>
[quoted text clipped - 72 lines]
> > > I still am not able to do it :(
> > > Paulo
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.