Setting the value of a date field in a repeating table equal to the field in the main data source in code using InfoPath 2003. - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Setting the value of a date field in a repeating table equal to the field in the main data source in code using InfoPath 2003.

Last post 02-18-2009 12:08 PM by Jermaine Cross. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 02-11-2009 09:06 AM

    Setting the value of a date field in a repeating table equal to the field in the main data source in code using InfoPath 2003.

    I have created a Time Sheet form. When I click on the datepicker to select the beginning date of the week (which is Sunday), I want that date to be place in the first row of the repeating table. When I reference the field which is (XDocument.DOM.selectSingleNode("/my:myFields/my:MainSelectionWeekOf") it brings back a date of 12/31/1969 which of course is not the date selected. I need this date to populate the rest of the weekdays and dates. I am using a SQL data connection. As I was researching I found that someone create a SetNodeValue function on the Expense Report template but when I tried it of course it do not work for me. I need help I have been struggling with this for 2 weeks now and I am heading towards my project deadline. Thanks in advance for assistance.

  • 02-16-2009 08:51 AM In reply to

    Re: Setting the value of a date field in a repeating table equal to the field in the main data source in code using InfoPath 2003.

    Okay, do you have the field MainSelectionWeekOf set as a Date data type?

    Hilary Stoupa

  • 02-16-2009 09:57 AM In reply to

    Re: Setting the value of a date field in a repeating table equal to the field in the main data source in code using InfoPath 2003.

    Yes I do I figured out that problem.

     function DayofWeek() { var xDoc = XDocument.DOM; var dt = xDoc.selectSingleNode("//my:MainSelectionWeekOf").text; var month = dt.substring(5,7); var date = dt.substring(8,11); var year = dt.substring(0,4); var ndate = month + "/" + date + "/" + year; var my_day=new Date(ndate); var day_name=new Array(7); day_name[0]="Sunday" day_name[1]="Monday" day_name[2]="Tuesday" day_name[3]="Wednesday" day_name[4]="Thursday" day_name[5]="Friday" day_name[6]="Saturday" return(day_name[my_day.getDay()]); }

    // Get Day of the week from date selected var dayField = XDocument.DOM.selectSingleNode("//my:DayoftheWeek"); dayField.text = DayofWeek();

    But now I need help with this: I have a problem with calculating a field in a repeating table. I am using say field1 - field2 to get a value and put it in field3. Can you help me with this. I tried doing this thru code in javascript and what i get is a null value for some reason. Thank you in advance.

     function TimeDiff() { var xDoc = XDocument.DOM; var time1 = Number(xDoc.selectSingleNode("/dfs:myFields/dfs:dataFields/d:TimeSheetMain/d:TimeSheetDetail/@In1").text); var time2 = Number(xDoc.selectSingleNode("/dfs:myFields/dfs:dataFields/d:TimeSheetMain/d:TimeSheetDetail/@Out1").text); var maxhrs = 24; var td1; { //Regular business hours if(time1time2){ td1 = maxhrs - time1 + time2; } return(td1); } }

    function msoxd__TimeSheetDetail_Out1_attr::OnAfterChange(eventObj) { var diff = eventObj.Site.selectSingleNode("../@Reg"); diff = TimeDiff(); }


  • 02-18-2009 08:50 AM In reply to

    Re: Setting the value of a date field in a repeating table equal to the field in the main data source in code using InfoPath 2003.

    I'm perplexed to see you casting the time as a number -- Will Javascript do that? I would think you'd need to cast the text to a datetime value and then get the difference. Here's a link to a site with some information on manipulating date and time with Javascript. The Timecard sample that shipped with IP 2003 also supposedly has this functionality -- you should take a look at it. I'll attach the template to this post -- right click the link in the post header and select 'Save As'. Then you can open it in design mode and look at the script it uses.

    Hilary Stoupa

  • 02-18-2009 12:08 PM In reply to

    Re: Setting the value of a date field in a repeating table equal to the field in the main data source in code using InfoPath 2003.

    The timecard template that is included with inofpath gives you a sum of the columns selecting all the nodes. I am trying to add one column to the next column which equals the third colum for each row.

     function msoxd_my_field5::OnAfterChange(eventObj) { // Write code here to restore the global state. if (eventObj.IsUndoRedo) { return; } var oField3 = eventObj.Site.selectSingleNode("../my:field3"); oField3.text = Calculate(); } function Calculate() { var f1 = Number(XDocument.DOM.selectSingleNode("//my:field1").text); var f5 = Number(XDocument.DOM.selectSingleNode("//my:field5").text); var sum; sum = f1 + f5; return(sum); }

    The code above describes what I have come up with but it keeps only adding the first row  as the sum for all entries in  the third row. I do believe that I am not quite sure how to specify each specific row to give a sum. I even tried using the position() method which I think might work.

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.