Skip to Content Skip to Menu

Complicated IF - Subtracting from a field value

12 years 1 week ago #200716 by marriage_minded_man
Complicated IF - Subtracting from a field value was created by marriage_minded_man
Ok. I want to have users put in their extension which is 6 digits long into a text field value.

When I pull that value I want to have an IF statement saying:

If the extension starts with the digits "11" output only the last 5 digits of the extention.

If the extension starts with the digits "10" output only the last 4 digits of the extension.

So all six digits are stored as a field value, but when I go to pull it to use it in a code I want it to output the last five digits if the six digits start with "11", or output the last four digits if the sex digits start with 10.

Is this possible???

So 2 questions really. Can I use something like wildcard stars "*" in order to identify whats in the field, like "[cb:if cb_field="10***"]" then output the last 4 digits.

And how to I subtract from a field value. Can I tell it to null characters in a field value or not display them?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 68625
  • Thanks: 9109
  • Karma: 1434
12 years 4 days ago - 12 years 4 days ago #200800 by krileon
IF substitutions have no way of counting the characters of a field value. You'll need to use CB Query Field to query for the field, count its characters, and output that as a SELECT query. The query field would then display the character count of that field instead of its value and you can then use that in your IF statement.

And how to I subtract from a field value. Can I tell it to null characters in a field value or not display them?

Same method as above, you'll need query field to do it.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 12 years 4 days ago by krileon.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum

Facebook Twitter LinkedIn