SetValue and Function Builder? - InfoPath Dev
in

InfoPath Dev

SetValue and Function Builder?

Last post 03-29-2012 11:43 AM by Hilary Stoupa. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 03-28-2012 07:57 AM

    SetValue and Function Builder?

    Hi all -

    I am in the process of trying out qRules and need a little help with the SetValue function.  I am working through the provided documentation on the SetValue command using an InfoPath 2010 filler form, since that's the type of form I need SetValue for.  I am working through the 2nd exercise where you use a 'concat' statement to use specific fields with dynamic values in the parameter (basically, this is to get the Filter and Value fields working.)  

    After renaming a few things to line up with how I prefer to work, what I need for my concat statement is

    concat("SetValue xpath=/my:myFields/my:Replacements/my:gpReplacements/my:txtReplacementText[../my:txtText='", txtFilter, "'] /value=", txtValue)

     I tried this, but it didn't work - no errors, just nothing happened.  However, I found a couple of posts that say that you need to build your 'concat' statement in the function builder.  I can add concat via the Function Builder easily enough, but when I try to paste in the things between quotes and pick only txtFilter and txtValue, I get the same result.   If there is another way where I can pick the things between the quotes, it's not obvious to me how to do that.

    I've had problems with it not being able to recognize the single quote when I paste that in, but even when I replace the single quotes manually, I get the same result.  Can someone please point me in the direction of what I may be doing wrong? 

    Thanks,

    nkstrou

    An imprecisely defined requirement has an infinite number of possible solutions. Unfortunately, only about a maxiumum of 3 solutions are actually satisfactory to the end user.
  • 03-28-2012 08:30 AM In reply to

    Re: SetValue and Function Builder?

    First, if you are using a concat statement, you must use the function builder.You'd pick txtFilter and txtValue using the field picker, most likely. Your formula above looks correct. Whe you say "I get the same result" what does that mean? Are you able to save your function? Any information in the Qdabra Rules error node?

    Hilary Stoupa

  • 03-28-2012 09:04 AM In reply to

    Re: SetValue and Function Builder?

    Same result = when I try to use the Set Value button (which I've associated a Set Value action rule with that uses the concat statement), nothing happens.

    Yes, I can save the function - when I use Verify Formula to check out what I've entered, it accepts it just fine and I can save it.

    The error node says "required parameter unspecified: xpath"   I've got to step into a meeting right now, but will come back and see if I can figure out what it doesn't like about how I've built the xpath parameter. 

    Thanks for the tip!

     nkstrou

    An imprecisely defined requirement has an infinite number of possible solutions. Unfortunately, only about a maxiumum of 3 solutions are actually satisfactory to the end user.
  • 03-28-2012 09:06 AM In reply to

    Re: SetValue and Function Builder?

    Your syntax is off. In your formula, you need a "/" before the word XPath.

    Hilary Stoupa

  • 03-28-2012 10:19 AM In reply to

    Re: SetValue and Function Builder?

    Ah!  That did it.  Many thanks!

    nkstrou

    An imprecisely defined requirement has an infinite number of possible solutions. Unfortunately, only about a maxiumum of 3 solutions are actually satisfactory to the end user.
  • 03-29-2012 08:26 AM In reply to

    Re: SetValue and Function Builder?

    OK, the syntax on this is driving me nuts trying to use the Function Builder.  I'm trying to use qRules and SetValue in my real InfoPath 2010 filler form now, only I don't think I need concat this time around. 

    Basically, whenever a certain radiobutton called optNonCSSPassFail is clicked, I want to update a radiobutton called optTestStatus in a particular row in my repeating table gpTestStats.  This should be easy, because each row in gpTestStats has a unique identifier. optTestStatus should be easy as well, because the default value is "Not Tested" and I want to change it to "Tested".  So when optNonCSSPassFail is clicked, I run an action rule to change the Command field's value  in the QdabraRules data connection as follows:

    Command = SetValue /xpath=my:myFields/my:TestStats/my:gpTestStats/my:optTestStatus[txtTestID = 'INC-01'] /value=Tested

    Only if I pick optTestStatus via the Function Builder, it basically complains that I'm trying to repeat the entire path all over again at the level of optTestStatus and if I remove the path and start with /xpath=optTestStatus etc. it complains that this isn't a valid location.  If I just paste the above into the Function Builder, it also complains that it isn't a valid location or group.

    What is it wanting from me?  And is there a guide to InfoPath syntax somewhere? 

    Thanks,

    nkstrou

    An imprecisely defined requirement has an infinite number of possible solutions. Unfortunately, only about a maxiumum of 3 solutions are actually satisfactory to the end user.
  • 03-29-2012 08:58 AM In reply to

    Re: SetValue and Function Builder?

    If you don't need to use concat, you don't need to use the Function Builder. Just paste your command in the Value box in the rule.

    Use Function Builder if you need a form value or an InfoPath function to create the string you wish to set the Command node to. In a case like this, where all the values are hard coded, just paste the command in the Value field in the rule dialog.

    Here's how qRules works. You change the value of the Command field using a rule. The code tries to do something based on the value of the Command field. Whether the value is something hard coded, like your sample above, or something created by a concat statement, like your earlier tests, the Command field does not care. Not one whit. All it cares about is the string value it is currently set to.

    Hilary Stoupa

  • 03-29-2012 09:00 AM In reply to

    Re: SetValue and Function Builder?

    If the command you want to use is just static text (i.e. it doesn't use concat() or anything like that), I wouldn't advise using the formula editor to build up the command.  You can just type it directly into the Value: box of the Set Value dialog.  If it's a particularly long command, you can build it up ahead of time using Notepad, and then paste it in.  To obtain the right XPaths for anything, you can just right-click the field in the data source taskpane and select Copy XPath.
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-29-2012 10:46 AM In reply to

    Re: SetValue and Function Builder?

    OK, thanks Hilary (and you, too, Jimmy!)

    Now I'm unclear on how Command is supposed to get executed now that I've set it to do what I want with my Action Rule.  Does qRules have some built-in code that executes it each time it gets set to something new, or do I *have to* use a button in order to execute it?

    Sorry for all the questions - I would have asked this above, but thought it might be distracting, since it's unrelated to matters of syntax.  I find that when I hit people with too many questions at once, they don't always answer them all.  So then I just end up driving them nuts with a series of serial questions, LOL.  Can't win for losing.

    I think I should be nearing the end of my questions, though.  I have a bunch of updates to my gpTestStats table that should work much like the one I just described.  So once I get this first instance working and feel like I understand it, it should be nothing but a lot of Copy Rule/Paste Rule and updating fieldnames and filters.

    Thanks,

    nkstrou

    An imprecisely defined requirement has an infinite number of possible solutions. Unfortunately, only about a maxiumum of 3 solutions are actually satisfactory to the end user.
  • 03-29-2012 10:55 AM In reply to

    Re: SetValue and Function Builder?

    When you set the Command field's value, the changed event executes the command and then clears the field. Your rule can be on any node other than the Command node itself. So if you have a field in your form named "field1", you can have a rule on it that sets the Command field, and that's all you need.

    Hilary Stoupa

  • 03-29-2012 11:37 AM In reply to

    Re: SetValue and Function Builder?

    There was some sort of problem earlier with the InfoPathDev server - I know I didn't receive an email when I was finally able to post this the first time, so I'm guessing none of the techs on this site did either.  I'm going to post my question again to see if one gets sent this time.

    ____________________

    OK, thanks Hilary (and you, too, Jimmy!)

    Now I'm unclear on how Command is supposed to get executed now that I've set it to do what I want with my Action Rule.  Does qRules have built-in code that executes it each time it gets set to something new, or do I have to use a button in order to execute it?

    Sorry for all the questions - I would have asked this above, but thought it might be distracting, since it's unrelated to matters of syntax.  I find that when I hit people with too many questions at once, they don't always answer them all.  So then I just end up driving them nuts with a series of serial questions, LOL.  Can't win for losing.

    I think I should be nearing the end of my questions, though.  I have a bunch of updates to my gpTestStats table that should work much like the one I just described.  So once I get this first instance working and feel like I understand it, it should be nothing but a lot of Copy Rule/Paste Rule and updating fieldnames and filters.

    Thanks,

    nkstrou

    An imprecisely defined requirement has an infinite number of possible solutions. Unfortunately, only about a maxiumum of 3 solutions are actually satisfactory to the end user.
  • 03-29-2012 11:43 AM In reply to

    Re: SetValue and Function Builder?

    Your post was posted - I answered directly above.

    When you set the Command field's value, the changed event executes the command and then clears the field. Your rule can be on any node other than the Command node itself. So if you have a field in your form named "field1", you can have a rule on it that sets the Command field, and that's all you need.

    Hilary Stoupa

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