Getting the local-name of a field via JScript Code - InfoPath Dev
in

InfoPath Dev

Getting the local-name of a field via JScript Code

Last post 02-26-2006 12:06 AM by rjohnson. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 02-23-2006 04:20 PM

    • rjohnson
    • Top 500 Contributor
    • Joined on 09-01-2005
    • Australia
    • Posts 28

    Getting the local-name of a field via JScript Code

    Hi all,

    Is it possible to use the function "local-name", within managed JScript Code.

    I tried simply typing in "local-name", and used a field from the data source as its parameter, but it comes up with an error.

    Any help would be appreciated.

    - Reg.
  • 02-23-2006 11:19 PM In reply to

    Re: Getting the local-name of a field via JScript Code

    Hi Reg,
    What does local-name function do? What is the error?

    Patrick Halstead [InfoPath MVP]
    InfoPath Dev Seattle
    Patrick Halstead
    Project Manager at Qdabra
  • 02-23-2006 11:51 PM In reply to

    • rjohnson
    • Top 500 Contributor
    • Joined on 09-01-2005
    • Australia
    • Posts 28

    Re: Getting the local-name of a field via JScript Code

    Hi Patrick,

    The local-name function:
    "Returns the local part of the expanded name of the node in the node-set argument that is first in document order"

    I basically want to use it to return the name of the datasource field.

    The full intent is to be able to create some script which will cycle through all elements in the datasource, and display a list of fields that have not met certain circumstances.

    The error that I am getting is:
    "Local is not defined", but that is because I simply entered local-name(XDocument.DOM.selectSingleNode("/my:myFields/my:field1").text); which I assume doesn't work because it doesn't know where the function is.

    Any help would be appreciated.

    Cheers,

    - Reg.
  • 02-24-2006 07:42 AM In reply to

    Re: Getting the local-name of a field via JScript Code

    Try this:

    XDocument.DOM.selectSingleNode("/my:myFields/my:field1").nodeName

    In this case, it should return "my:field1".

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 02-26-2006 12:06 AM In reply to

    • rjohnson
    • Top 500 Contributor
    • Joined on 09-01-2005
    • Australia
    • Posts 28

    Re: Getting the local-name of a field via JScript Code

    Thanks a lot for the idea MFaus.

    The only problem with your solution is that it adds a "my:" at the start.

    However, after some research, I found a way to get just the name of the field: If you use
    XDocument.DOM.selectSingleNode("/my:myFields/my:field1").baseName
    it will return field1 only.

    Thanks again for your help.

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