We are currently performing maintenance on Appian Community. As a result, discussions posts and replies are temporarily unavailable. We appreciate your patience.
So I was finally able to get some phone number validation working. However, it only works in the interface and not when I'm actually using the record action.
Here's the code the error message I'm getting. I think this is happening because the record action relies on user input and perhaps starts off as null. I'm just hoping there's a way to fix it.When I try to create a new contractor through the record action: Error Evaluating UI Expression Expression evaluation error [evaluation ID = 0932b:f622d] in rule 'ds_createcontractor' at function 'search' [line 65]: A null parameter has been passed as parameter 2.
a!textField( label: "Phone Number ", labelPosition: "ABOVE", placeholder: "### - ### - ####", saveInto: ri!record['recordType!{d327a5dc-18d4-4ffd-8bdf-6a22b134677f}DS Contractor.fields.{f4c57b1e-a70b-4b5c-abfd-91fbfa77c38f}conPhoneNumber'], refreshAfter: "UNFOCUS", required: true, value: ri!record['recordType!{d327a5dc-18d4-4ffd-8bdf-6a22b134677f}DS Contractor.fields.{f4c57b1e-a70b-4b5c-abfd-91fbfa77c38f}conPhoneNumber'], validations: {if( search("-", ri!record['recordType!{d327a5dc-18d4-4ffd-8bdf-6a22b134677f}DS Contractor.fields.{f4c57b1e-a70b-4b5c-abfd-91fbfa77c38f}conPhoneNumber'],8)<3, "Please enter hyphens between the numbers.", {} )} ),
Usually looks like this:
Discussion posts and replies are publicly visible
your search() command looks suspect.
you're saying, "search( "-", [phone number], 8)"
which means, "search the entered phone number for hyphens, starting at the 8th character"
That doesn't seem to fit what you actually want, though.
Starting at the correct index doesn't seem to change things, unfortunately
What are you hoping to accomplish via the "< 3" part of the expression?
It's for if there are less than 3 hyphens then the validation message would kick in (which it does, just not with the record action)
search() returns the first index of the character you're searching for, not the total instances.
Is there a way to search for the total instances? I'm unable to download the regex plugin for some reason so not sure that I can use much regex
What I usually do with this sort of thing is use split() on the separator, like "split(ri!number, "-")" which returns an array containing all of the parts of the string as separated by "-" characters, and in that sense it should actually work about what you were trying above - if there are less than 3 results, it means they haven't separated at least 3 parts of the string with dashes.