AnsweredAssumed Answered

Using Set Field By Name in Find Mode with Variables

Question asked by Gale on May 16, 2014
Latest reply on May 20, 2014 by philmodjunk


Using Set Field By Name in Find Mode with Variables


     My application needs a lot of complicated find scripts. There are so many different variations and requirements that it would be nice be as flexible as possible, and avoid all of the repetition involved in setting up all of those different scripts. The concept outlined by six.fried.rice at the link
     describes exactly what I’d like to do. 
     Basically, a dictionary concept is used to pass pairs of field names and values to the script. The dictionary pairs are parsed in a loop and Set Field Value is used to put the value into the appropriate fields on the appropriate form used for searching.
     For lack of a better imagination, consider the following. 
     Cartype Colours Options
     Convertible,  Red,  AC
     2-door ,Blue, Hand-held fan
     4-door, Black, Heating
                  Grey, Blanket
     Along with this information are a lot of other related records. In this particular instance, users may want to search for red convertibles, 4-doors with AC, whatever combination suits their mood.
     Assuming the user is on the correct layout, here’s the basic script:
     SetVariable[$parms; Value:Get(ScriptParameter) //push search parms into script
       Set Variable[$fieldname; MyCustomFunctionforParsing($parm)] //get field name
       Set Variable[$fieldvalue; MyCustomFunctionforParsing($parm)] //get field value
       Set Field By Name [$fieldname; $fieldvalue]
       CustomFunctionforStrippingOutInfo[$parm] //removes the first field/value pair from the string
       Exit Loop If(IsEmpty($parm)]
     End Loop
     Perform Find[]
     I’ve stepped through this code and see the right things going on with respect to $fieldName, $fieldValue and $parm. When it comes to Set Field By Name though, it does not put the values in the fields as expected. Replacing it with SetField DOES work, but that’s not going to work for me. Any suggestions on what might be wrong here?