ReplaceText error - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

ReplaceText error

Last post 05-05-2015 11:01 AM by Hilary Stoupa. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 05-05-2015 10:25 AM

    ReplaceText error


    I am getting the following error when trying to use the ReplaceText function. I am sure it is because of my use of the current() function in my xpathsrc statement.

    Action: ReplaceString. Arguments: xpathsrc: current()/my:WO_TEXT string1: |1| string2: Stain & Varnish . 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.CompiledXpathExpr.SetContext(IXmlNamespaceResolver nsResolver) 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 start, String xpath, String errorMessage) at Qdabra.Tools.RulesLibrary.ReplaceString.DoSingleReplace(String dsnamesrc, String xpathsrc, String string1, String string2, String pattern) at Qdabra.Tools.RulesLibrary.ReplaceString.Execute() at Qdabra.Tools.RulesLibrary.CommandStarter.Run() at Qdabra.Tools.RulesLibrary.Commands.RunCommand(Commands command) at Qdabra.Tools.RulesLibrary.Commands.ExecuteCommand()

    My QRules command is " concat("ReplaceString /xpathsrc=current()/my:WO_TEXT /string1=|Q| /string2=", ../my:WOQty)". I am in a repeating table trying to replace a token ("|Q|") in the current row's WO_Text with the value of the current row's quantity.

  • 05-05-2015 10:33 AM In reply to

    Hi - You'll need to use the full path to WO_TEXT and use a count of preceding-sibling to get the right one. Can you right click WO_TEXT in the data source task pane and select Copy XPath? Paste the full XPath into a reply and I can help you.

    Hilary Stoupa

  • 05-05-2015 10:39 AM In reply to

    Thanks, Hilary!

    the full xpath is: /my:RCInspection/my:WorkOrders/my:WorkOrder/my:WO_TEXT

  • 05-05-2015 10:43 AM In reply to

    Try this:

     concat("ReplaceString /xpathsrc=/my:RCInspection/my:WorkOrders/my:WorkOrder[",count(../preceding-sibling::my:WorkOrder) + 1,"]/my:WO_TEXT /string1=|Q| /string2=", ../my:WOQty)"

    I forgot to ask where the rule is running - it looks like on a field inside of WorkOrder (based on the relative path to WOQty). If I've guessed wrong, you may have an issue with this XPath: ../preceding-sibling::my:WorkOrder

    So, if this doesn't work, let me know what executes the rule. :)

    Hilary Stoupa

  • 05-05-2015 10:53 AM In reply to

    It worked! It is actually happening with any changes on the WO_TEXT field (assuming the WO_Text field has a |Q| or |1| token in it...I have another similar rule that checks for |1|). Thank you so much!
  • 05-05-2015 11:01 AM In reply to

    You bet - so, just in case you need some details (or in case someone else happens along this post and needs deets):

    The count of the preceding repeating node returns a number of 0 or more (if this is the first row, it has no preceding siblings, after all) and by adding 1 we get the index for the current row.

    In qRules, the Command node is just parsing the string we pass it and attempting to run the code requested. Using the concat statement, we are giving it an XPath to the correct Work Order row - like my:WorkOrder[2] or my:WorkOrder[5], etc. This way the code can select the right row.

    Hilary Stoupa

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