Jscript Error - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Jscript Error

Last post 11-14-2008 07:05 AM by m181354. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 11-13-2008 04:21 AM

    Jscript Error

    I get the following error when I run the code below.  Does anyone see a problem with the code?  The line 98 already ends with ";"

    ERROR

    Form template: file:///C:\Documents%20and%20Settings\M181354\Desktop\PCAS%20Change%20Request%20Form.xsn
    InfoPath cannot open the selected form because of an error in the form's code.
    The following error occurred:

    Expected ';'
    File:script.js
    Line:98
    var listService As New WebList.Lists();

    CODE 

    var listService As New WebList.Lists();
    listService.Credentials = System.Net.CredentialCache.DefaultCredentials;

    var viewstr As String = "{2EE4BCFF-5BC6-4B8E-A60F-5B733E89813A}";
    var strBatch As String = "<Method ID='1' Cmd='New'>" +  "<Field Name='ID'>New</Field>" +  "<Field Name='Title'>"1"</Field>" +  "<Field Name='CR%5FNumber'>"CR_0001"</Field>" +  "<Field Name='Change%5Fx0020%5FRequest%5Fx0020%5FTitle'>KaverTitle</Field>" +  "<Field Name='Description'>KaverDescription</Field>" +  "</Method>";

    var xmlDoc As New XmlDocument();

    var elBatch As System.Xml.XmlElement = xmlDoc.CreateElement("Batch");
    elBatch.InnerXml = strBatch;

    var ndReturn As XmlNode = null;
    Try;
      ndReturn = listService.UpdateListItems(viewstr, elBatch);
      Catch ex As System.Web.Services.Protocols.SoapException;
      MessageBox.Show(ex.Detail.InnerXml);
      Exit Sub;
    End Try;

     

     

    Filed under: , ,
  • 11-13-2008 04:33 AM In reply to

    Hi,Once replace the  var strBatch As String = "<Method ID='1' Cmd='New'>" +  "<Field Name='ID'>New</Field>" +  "<Field Name='Title'>"1"</Field>" +  "<Field Name='CR%5FNumber'>"CR_0001"</Field>" +  "<Field Name='Change%5Fx0020%5FRequest%5Fx0020%5FTitle'>KaverTitle</Field>" +  "<Field Name='Description'>KaverDescription</Field>" +  "</Method>"; with the following and try. var strBatch As String = "<Method ID='1' Cmd='New'>" +  "<Field Name='ID'>New</Field>" +  "<Field Name='Title'>1</Field>" +  "<Field Name='CR%5FNumber'>CR_0001</Field>" +  "<Field Name='Change%5Fx0020%5FRequest%5Fx0020%5FTitle'>KaverTitle</Field>" +  "<Field Name='Description'>KaverDescription</Field>" +  "</Method>"; 

     

    Swathip
    www.ggktech.com
  • 11-13-2008 07:01 AM In reply to

    Thank you for your quick response.  I changed my code but I am still getting the same error on line 98.  I have a semi-colon so I do not understand why I get the error on that line.

    InfoPath cannot open the selected form because of an error in the form's code.
    The following error occurred:

    Expected ';'
    File:script.js
    Line:98
    var listService As New WebList.Lists();

    CODE
    var listService As New WebList.Lists();
    listService.Credentials = System.Net.CredentialCache.DefaultCredentials;

    var viewstr As String = "{2EE4BCFF-5BC6-4B8E-A60F-5B733E89813A}";
    var strBatch As String = "<Method ID='1' Cmd='New'>" +  "<Field Name='ID'>New</Field>" +  "<Field Name='Title'>"1"</Field>" + "<Field Name='CR%5FNumber'>"CR_0001"</Field>" + "<Field Name='Change%5Fx0020%5FRequest%5Fx0020%5FTitle'>KaverTitle</Field>" + "<Field Name='Description'>KaverDescription</Field>" +  "</Method>";

    var xmlDoc As New XmlDocument();

    var elBatch As System.Xml.XmlElement = xmlDoc.CreateElement("Batch");
    elBatch.InnerXml = strBatch;

    var ndReturn As XmlNode = null;
    Try;
      ndReturn = listService.UpdateListItems(viewstr, elBatch);
      Catch ex As System.Web.Services.Protocols.SoapException;
      MessageBox.Show(ex.Detail.InnerXml);
      Exit Sub;
    End Try;

    Filed under: ,
  • 11-13-2008 08:22 AM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Hello,

    Here is the strBatch string to set the .innerXml value in your code,

    <Method ID='1' Cmd='New'><Field Name='ID'>New</Field><Field Name='Title'>1</Field><Field Name='CR%5FNumber'>CR_0001</Field><Field Name='Change%5Fx0020%5FRequest%5Fx0020%5FTitle'>KaverTitle</Field><Field Name='Description'>KaverDescription</Field></Method>

    Are you able to set the strBatch value to set elBatch.InnerXml value? If yes then can you give more detail on where you are getting the error?

  • 11-14-2008 07:05 AM In reply to

    The code falis on the line 98 so I do not know if the code you have listed is working.

    ERROR

    InfoPath cannot open the selected form because of an error in the form's code.
    The following error occurred:

    Expected ';'
    File:script.js
    Line:98
    var listService As New WebList.Lists();

    CODE for Line 98
    var listService As New WebList.Lists();

    I originally got the code in VBScript from here.    http://www.infopathdev.com/forums/p/7997/29085.aspx#29085 

    I converted the VBScript code to JScript using this site    http://slingfive.com/pages/code/scriptConverter/demo.html

     

     ALL CODE

    var listService As New WebList.Lists();
    listService.Credentials = System.Net.CredentialCache.DefaultCredentials;

    var viewstr As String = "{2EE4BCFF-5BC6-4B8E-A60F-5B733E89813A}";
    var strBatch As String = "<Method ID='1' Cmd='New'>" + "<Field Name='ID'>New</Field>" + "<Field Name='Title'>"1"</Field>" + "<Field Name='CR%5FNumber'>"CR_0001"</Field>" + "<Field Name='Change%5Fx0020%5FRequest%5Fx0020%5FTitle'>KaverTitle</Field>" + "<Field Name='Description'>KaverDescription</Field>" + "</Method>";

    var xmlDoc As New XmlDocument();

    var elBatch As System.Xml.XmlElement = xmlDoc.CreateElement("Batch");
    elBatch.InnerXml = strBatch;

    var ndReturn As XmlNode = null;
    Try;
      ndReturn = listService.UpdateListItems(viewstr, elBatch);
      Catch ex As System.Web.Services.Protocols.SoapException;
      MessageBox.Show(ex.Detail.InnerXml);
      Exit Sub;
    End Try; 

     

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