Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Getting Started, Learning, Etc.

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 6th, 2022, 08:03 AM
ryanceot ryanceot is offline
Forum n00b
 
Join Date: Feb 2020
Posts: 9
Default Contains Command

I'm given fields with multiple characters where each character is used to "turn on" content within a rule. The order of the characters is random. How do I write a rule to tell FusionPro to look for a certain character within a string, ignore all other characters, and the order of the characters?

Example:
Field Name = Optional
Field String 1 = AXYD
Field String 2 = DYXA

If X is in string show content 1.
If Y is in string show content 4.

I'm already using rules that show content based on an exact string match and am looking for the flexibility to show content based on contains vs. an exact match.

Thank you for any assistance you can provide!

-Ryan
Reply With Quote
  #2  
Old April 6th, 2022, 10:39 AM
ThomasLewis's Avatar
ThomasLewis ThomasLewis is offline
Senior Contributor
 
Join Date: Feb 2011
Posts: 233
Default Re: Contains Command

if (Field("FieldName").indexOf("AAAA") > -1)

This returns the index of "AAAA" within the given string starting with 0.
For instance if your string is "zzzAAAAzzz" it would return 3.
If your string is "zzzBBBBzzz" it would return -1 because the search string is not found.
So, if it returns greater than -1, then you have a match.
Reply With Quote
  #3  
Old April 7th, 2022, 02:11 PM
ryanceot ryanceot is offline
Forum n00b
 
Join Date: Feb 2020
Posts: 9
Default Re: Contains Command

Hi Thomas,

Thank you for the response. I'm not sure my question is clear.

I need FusionPro to look at a field that will contain multiple characters in random order. Then tell FusisionPro to show content when a field contains a specific character regardless of where it is in the string.

Example: If field "PTO" contains "A" display "Lakeland, FL".

Strings in PTO could be "124Abd3", "A3429", or just simply "A".

Thanks,
Ryan
Reply With Quote
  #4  
Old April 8th, 2022, 05:13 AM
MartyrSyx's Avatar
MartyrSyx MartyrSyx is offline
Regular Contributor
 
Join Date: Sep 2008
Location: Westerville, Ohio
Posts: 73
Default Re: Contains Command

if (Field("PTO").indexOf("A") > -1)
__________________
Brad Mather
WestCamp
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:17 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.