Crash when trying to display a [?Prompt]

I am trying to implement some automation to allow my users to edit some Entity Custom Data, but when editing the data I would like them to see the current values and that way they can choose if they want to change anything or not.

This is easy enough using the [?Prompt;;OldValue] syntax, but I also need to use a drop-down selection of values for one particular field. Therefore for this multi select box I thought I would do the following: [?Prompt (OldValue);;Option1|Option2|Option3]

Side thought Is there any way to implement the drop-down selection but start with one particular option already selected? Something like [?Prompt;;Monday|Tuesday|»Wednesday«|Thursday|Friday] Where Wednesday would be selected as the default option?

The problem

I set up my rule as you can see in the image below, but I got the error:
DevExpress.Xpf.Editors.TextEditor Threw and exception

A little something from the log…

Top-level Exception
Type:        System.ArgumentException
Message:     syntax error
Source:      DevExpress.Data.v16.2
Stack Trace: at DevExpress.Data.Mask.RegExpParser.yyerror(String message, String[] expected)
   at DevExpress.Data.Mask.RegExpParser.yyparse(yyInput yyLex)
   at DevExpress.Data.Mask.RegExpParser.Parse(TextReader reader, Boolean reverseAutomate, CultureInfo parseCulture)
   at DevExpress.Data.Mask.RegExpParser.Parse(String regExp, Boolean reverseAutomate, CultureInfo parseCulture)
   at DevExpress.Data.Mask.RegExpMaskManagerCore..ctor(String regExp, Boolean reverseDfa, Boolean isAutoComplete, Boolean isOptimistic, Boolean showPlaceHolders, Char anySymbolPlaceHolder, CultureInfo managerCultureInfo)
   at DevExpress.Xpf.Editors.TextInputMaskSettings.CreateDefaultMaskManager()
   at DevExpress.Xpf.Editors.TextInputMaskSettings.DevExpress.Xpf.Editors.IMaskManagerProvider.CreateNew()
   at DevExpress.Xpf.Editors.WpfMaskManager.Initialize()

I tried the rule without the “Dive Level” section to the rule and it worked fine, so the underlying concept seems OK, but for some reason it is not happy when I implement this approach with the drop-down list.

I noticed your missing (2) ;; in your prompt, there should be 4. Although, that’s not causing your crash. If you put your options behind the last ; and put double quotes around them, that will give you a custom keyboard of your options. You than can place your default value behind the second quote.

Source:

I don’t quite understand what you are suggesting? I was trying to have the exisitng “Dive Level” appear as part of the label and then have a selection drop-down to choose which one they would like to set.

In the end, I replaced the whole multiple prompt stuff with a single prompt for the name and then a series of “Ask Question” actions to set the other stuff (I used some script logic to automatically highlight using color the exisiting option).

The script is below in case it helps anyone…

function getButtonList(option,entity) {
// One of these arrays will be used to build the list of options to be presented to the user
var optDiveLvel = ["DSD", "OW", "OW+Deep", "AOW", "Rescue", "MSD", "Professional"];
var optBCD  = ["Personal", "100", "200", "300", "400", "500", "600", "700", "Other"];
var optFins  = ["Personal", "100", "200", "300", "400", "500", "600", "700", "800", "900", "Other"];
var optRegulator  = ["Personal Yoke", "Personal DIN", "Rental", "Other"];
var optMask  = ["Personal", "Black", "Green", "Red", "Purple","Yellow", "Junior",  "Other"];
var optWetsuit  = ["Personal", "XS Female", "S Female", "M Female", "L Female", "XL Female", "S Male", "M Male", "L Male", "XL Male", "XXL Male", "Other"];
// Find the current value of this particular piece of custom data for the given entity
var qry = "SELECT jsonValue FROM Entities CROSS APPLY OPENJSON(CustomData) WITH (jsonName varchar(50) '$.Name', jsonValue varchar(50) '$.Value') jsonData WHERE jsonName = '"+option+"' and Name = '"+entity+"'";
var currentValue = sql.Query(qry).First;
// Set some default colors for the buttons
var defaultColor = 'LightGray';
var defaultHoverColor = 'Gray';
// Set some colors that we will assign to the button representing the existing value
var currentColor = 'Green';
var currentHoverColor = 'DarkGreen';
var output = '';
var arr;
// We need to choose which array we are going to loop through
// There is probably a much better way to do this, but I don't
// know the equivilent of ${$'opt' . $option} php notation in JScript.
switch (option) {
  case 'BCD':
    arr = optBCD;
    break;
    case 'Mask':
    arr = optMask;
    break;
    case 'Fins':
    arr = optFins;
    break;
    case 'Regulator':
    arr = optRegulator;
    break;
  case 'Wetsuit':
    arr = optWetsuit;
}

for (var i = 0, len = arr.length; i < len; i++) {
  if (arr[i] == currentValue) {
    output = output + arr[i]+'='+arr[i]+':'+currentColor+';'+currentHoverColor+',';
    } else {
    output = output + arr[i]+'='+arr[i]+':'+defaultColor+';'+defaultHoverColor+',';
    }
}

return output;
}

I then stored some values and added a series of Ask Questions like this…

As you can see, buy hiding a lot of crap in the script I was able to keep the Ask Question rule pretty simple.

The syntax for [?prompt] is

[?<prompt>;<mask>;<default value>;<flags>;<keycodes>]

<mask> part evaluates as a regular expression. As the error message says there is a syntax error in regular expression, probably part of your CALL result reads as mask.

Edit: Only the first item of the list can be selected as default. To do that you can start value list with a * character like *Option1|Option2|Option3. Selecting values other than first value by default not implemented yet.

1 Like