AngelBenitez Posted July 20, 2023 Share Posted July 20, 2023 Hello, I am trying to create a rule that would include the Choose Phone Format option with all dots (123.456.7890) to the code below. if (Field("ChoosePhone") == "Direct" && Field("Direct") != "") { return Field("Direct"); } else if (Field("ChoosePhone") == "Mobile" && Field("Mobile") != "") { return Field("Mobile"); } else if (Field("ChoosePhone") == "Center" && Field("CenterPhoneNumber") != "") { return Field("CenterPhoneNumber"); } else { return Field("Direct"); } Does anyone know how I would go about this? Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted July 20, 2023 Share Posted July 20, 2023 If you're in FP 11 or later, then the code you have in that JavaScript rule is fine, and you don't need to make any changes at all to it. What you need to do is create a new rule, select the "Choose Phone Format" Form Rule, select the name of your JavaScript rule in the "choose field" drop-down list, then select your format. Then use that form rule in your text frame, and it will format the phone number selected by your script logic. 1 Quote Link to comment Share on other sites More sharing options...
AngelBenitez Posted July 21, 2023 Author Share Posted July 21, 2023 Hello @Dan Korn; that's what I want to avoid. I don't want to create a rule to depend on another rule. I only want one rule in the rules to achieve the same result. Is this possible to do? Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted July 21, 2023 Share Posted July 21, 2023 10 hours ago, AngelBenitez said: Hello @Dan Korn; that's what I want to avoid. I don't want to create a rule to depend on another rule. I only want one rule in the rules to achieve the same result. Is this possible to do? I don't understand your aversion to nested rules, but I suppose if you want to do this all in one rule, then you could just create the "Choose Phone Format" rule with the desired formatting, then convert it to JavaScript, and add any other logic you want. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.