• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFIF Statement

Engaged ,
Dec 05, 2016 Dec 05, 2016

Copy link to clipboard

Copied

Hi. I am trying to create a CFIF statement to search for part of our part numbers. For instance, we have part numbers like C1000 or C1300, etc. We also have part numbers like SG-BGA-6000 or PC-PLCC-2000.

What I would like the If statement to do, is to tell me if there are any C Numbers, then send an email. How do you create an If Statement for part numbers that begin with C and have numbers after it? Thanks for anyone's help.

Andy

TOPICS
Getting started

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 10, 2016 Dec 10, 2016

jamie61880 wrote:

Do you have any ideas as to how to even get the If Statement above to output "Yes!!!"?

Yes. Sorry there was a typing error in my last post. Those lines should be, respectively,

<cfif left(form["Part_Number#id#"],1) EQ "C" AND refindnocase("^[cC][0-9]", form["Part_Number#id#"])>

and

<cfif refindnocase("^[cC][0-9]{4}", form["Part_Number#id#"]) GT 0>

You are having difficulties because of <cfif "form.Part_Number#id#" IS 'P15552A'>. Observe that "form.Part_Number#id#" is not necessarily

...

Votes

Translate

Translate
Community Expert ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

Do you mean you want to identify part-numbers like C1234, CA-DBE-1234, and so on? If so, then you could just test whether the first character is c or C and whether the last character is a digit. Something like this:

<cfset partNumber="C1234">

<cfif uCase(left(partNumber,1)) is 'C' and isNumeric(right(partNumber,1))>

    <!---A hit. Send e-mail--->

<cfelse>

    A miss.

</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

BKBK,

     I was able to get a little different code to work that is below, but it only works on the first page that displays the info. to update, but I'm having a problem with it on the page after the Update button is clicked. That's where I want to send the email out from. This code should work from the part number field from the form on the page before, correct?

For right now, I am just trying to get a "Yes!!!" to display in the table on the page after the Update button is clicked if the part number is a C Number. If not, display "No!!!". The form.Part_Number#id# I think is written like this because of how our  query is set up. But when I use the code below, the only thing that displays is "No!!!". Some of the part numbers that are displaying are C Numbers, so I'm not sure why they are not saying "Yes!!!", especially if it's working on the page before. The only difference is the output tags. What am I doing wrong?

<td width="auto">

<cfif left("form.Part_Number#id#",1) EQ "C" AND refindnocase("^[cC][0-9]", "form.Part_Number#id#")>

YES!!!

<cfelse>

NO!!!</cfif>

</td>

Thanks.

Andy

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

It seems what you are aiming for is:

<cfif left(form[Part_Number#id#],1) EQ "C" AND refindnocase("^[cC][0-9]", form[Part_Number#id#])>

Anyway, this is incomplete: first part tests for "C" and not "c". Also, the second test repeats the first: both test if first letter is a C.

If all you want is a test for cxxxx or Cxxxx, where x is a digit, then your second test is good to go:

<cfif refindnocase("^[cC][0-9]{4}", form[Part_Number#id#]) GT 0>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 09, 2016 Dec 09, 2016

Copy link to clipboard

Copied

BKBK,

     Yes, this works too: <cfif refindnocase("^[cC][0-9]{4}", "form.Part_Number#id#") GT 0>. Just had to remove the [] and put a dot after form. But I'm still having an issue with the If statement not outputting "Yes!!!". Even if I try and with an exact part number, the If statement still outputs "No!!!". Here's what I tried:

<cfif "form.Part_Number#id#" IS 'P15552A'>

YES!!!

<cfelse>

NO!!!</cfif>

I'm guessing it has to do something with the #id#. I do have this also for where the id comes from:

<cfloop index="id" list="#form.listofids#" delimiters=",">

I really don't remember why we needed this id, but I think it was because of the way our database was set up. Do you have any ideas as to how to even get the If Statement above to output "Yes!!!"? If that works, then I could incorporate the refindnocase code.

Andy

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 10, 2016 Dec 10, 2016

Copy link to clipboard

Copied

jamie61880 wrote:

Do you have any ideas as to how to even get the If Statement above to output "Yes!!!"?

Yes. Sorry there was a typing error in my last post. Those lines should be, respectively,

<cfif left(form["Part_Number#id#"],1) EQ "C" AND refindnocase("^[cC][0-9]", form["Part_Number#id#"])>

and

<cfif refindnocase("^[cC][0-9]{4}", form["Part_Number#id#"]) GT 0>

You are having difficulties because of <cfif "form.Part_Number#id#" IS 'P15552A'>. Observe that "form.Part_Number#id#" is not necessarily the value of a form field. It is just a string containing the characters f, o, r, and so on. What you want is

<cfif form["Part_Number#id#"] IS 'P15552A'>

Even better:

<cfset partNumberField = "Part_Number" & id>

<cfif form[partNumberField] IS 'P15552A'>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 12, 2016 Dec 12, 2016

Copy link to clipboard

Copied

LATEST

BKBK,

    The first 2 lines above worked great! Yes, it was just from the typing error with the quotes. Thank you very much! I really appreciate it.

Andy

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation