Insert node within nested repeating node - InfoPath Dev
in

InfoPath Dev

Insert node within nested repeating node

Last post 11-05-2010 07:03 AM by joanfuture. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 11-05-2010 05:10 AM

    Insert node within nested repeating node

    Hallo,

    i cannot seem to get the following to work: I want to add a child to a repeating node, that itself is part of repeating node.

    my:form
        my:people
            my:person (repeating)
                my:ActiveDirectoryFields 
                    my:propertyData (repeating)      (add new node here for a certain person-node)

    I tried the following Command for Qrules:
    Insert /parent=/my:form/my:people/my:person[my:UserName=current()/../my:UserName]/my:ActiveDirectoryFields /child=my:PropertyData

    Qrules throws this message:
    An unexpected error occurred executing the rule. Action: Insert
     Arguments:
    parent: /my:UserDataChangeRequest/my:people/my:person[my:UserName=current()/../my:UserName]/my:ActiveDirectoryFields
    child: my:PropertyData

     Details: XsltContext is needed for this query because of an unknown function.
    Stack:   at MS.Internal.Xml.XPath.CompiledXpathExpr.UndefinedXsltContext.ResolveFunction(String prefix, String name, XPathResultType[] ArgTypes)
       at MS.Internal.Xml.XPath.FunctionQuery.SetXsltContext(XsltContext context)
       at MS.Internal.Xml.XPath.BaseAxisQuery.SetXsltContext(XsltContext context)
       at MS.Internal.Xml.XPath.BaseAxisQuery.SetXsltContext(XsltContext context)
       at MS.Internal.Xml.XPath.LogicalExpr.SetXsltContext(XsltContext context)
       at MS.Internal.Xml.XPath.FilterQuery.SetXsltContext(XsltContext input)
       at MS.Internal.Xml.XPath.BaseAxisQuery.SetXsltContext(XsltContext context)
       at MS.Internal.Xml.XPath.CompiledXpathExpr.SetContext(XmlNamespaceManager nsManager)
       at System.Xml.XPath.XPathExpression.Compile(String xpath, IXmlNamespaceResolver nsResolver)
       at System.Xml.XPath.XPathNavigator.SelectSingleNode(String xpath, IXmlNamespaceResolver resolver)
       at Qdabra.Tools.RulesLibrary.Commands.GetValidNode(XPathNavigator dom, String xpath, String errorMessage)
       at Qdabra.Tools.RulesLibrary.Commands.Insert()
       at Qdabra.Tools.RulesLibrary.Commands.ExecuteCommand()

    Do you know, if this is at all supported?

    I also tried to just hardcode the query but to no avail:
    Insert /parent=/my:UserDataChangeRequest/my:people/my:person[my:UserName = "abc"]/my:ActiveDirectoryFields /child=my:PropertyData

    Then I get this message:
    An error has occurred executing the rule. Failed to select the child node.

    Can you help me please?
    Thank you
    Michel

    Filed under: ,
  • 11-05-2010 05:52 AM In reply to

    Re: Insert node within nested repeating node

    The problem with your first approach is that the current() function is only available within InfoPath designer features (rules, condt'l formatting, etc.) and not in code-based features.

     To get around this, you can use a concat() statement to fold the value you want into the command:

    concat('Insert /parent=/my:form/my:people/my:person[my:UserName="', current()/../my:UserName, '"]/my:ActiveDirectoryFields /child=my:PropertyData')

    This way InfoPath will evaluate current()/../my:UserName before the command is sent to qRules. Pay special attention to the use of apostrophes and quotes near the commas.

    In order to use the Insert command within nested nodes, you must use a special parameter called xpathsrc, which should be the full path to the child node without any filtering:

    /xpathsrc=/my:form/my:people/my:person/my:ActiveDirectoryFields/my:PropertyData

    This parameter is a very new feature (added 9/29/2010) so please let us know if it is not available in your copy of qRules.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 11-05-2010 07:03 AM In reply to

    Re: Insert node within nested repeating node

     Hi Jimmy,

    thank you for quick response, you provide excellent help in this forum.

    I hadn't noticed I was using qrules 2.2 in that form. so I just injected 2.3 :-) (I love it)

    concat('Insert /parent=/my:UserDataChangeRequest/my:people/my:person[my:UserName="', current()/my:UserName, '"]/my:ActiveDirectoryFields /xpathsrc=/my:UserDataChangeRequest/my:people/my:person/my:ActiveDirectoryFields/my:PropertyData') 

    So instead of /child I use the new /xpathsrc-parameter and everything worked right away. I am quite impressed.
    This parameter by the way is not documented in the 2.3 User Guide. Are there any other cool parameters? :-)

    Thankyou, what a nice friday :-) have a nice weekend
    Michael

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