Good morning,
I am trying to create a command that adds the main contacts that speak a certain language and have a Mobile Phone Number to a collection. In excel, finding out whether the main contact has a phone number would look something like this: =IF('Mobile Phone Number'<>"", TRUE, FALSE)
.
The code below does not work, but I hope you get the idea.
'Add Supplier Recipients': command {
} as $'args' => walk ^ ^ .'Suppliers'* as $'c' (
switch $'c'.'Communication'.'Has Main Contact' (
|'No' => ignore
|'Yes' as $ => switch $ >'Main Contact' (
| none => ignore
| node as $'MC' => switch ^ .'Languages'[ $'MC' .'Language'] (
| none => ignore
| node => switch $'MC'>'Mobile Phone Number' (
| none => ignore
| node => update ^ .'Recipients' = create (
'Recipient' = $'MC' .'Recipient'
So the 'Mobile Phone Number'
is a text property?
It would be easier if you converted this to a stategroup ‘Has Mobile Phone Number’, so you can do a switch on the Yes/No states.
1 Like
Yes it is text property. I know it’s not possible to do a node switch like below with text property. The stategroup would solve the problem in my initial command. How do I convert Mobile Phone Number if it has text into a stategroup with ‘Yes’?
'Mobile Phone Number': text
'Mobile Phone Number exists': stategroup = switch >'Mobile Phone Number' (
| none => 'No' ( )
| node => 'Yes' ( )
) (
'Yes' { }
'No' { }
)
I think the proposal would be:
'Mobile Phone Number': stategroup (
'Unknown' { }
'Known' {
'Phone Number': text @validate: "[+0-9]{8, 11}" @description: "Enter a valid number, please"
}
)
It is also possible to do a @validate: “” on the text then, as you can see. I am not fully sure about the correctness of the regular expression, I should add. You can use an online javascript regular expression editor & validator to get what you want and there are probably lots of examples of this for phone numbers
1 Like