1 Reply Latest reply on Jul 12, 2012 2:39 PM by CANWizard

    Why Does My Pattern Count Return False?

    CANWizard

      Title

      Why Does My Pattern Count Return False?

      Post

      I have a script that processes fulfillment orders and currently have to add one more extra functionality to it.  We have added 2 different countries of origin coffee can be bought from, either Nicaragua or Veracruz.  The script currently outputs a reference code such as 2G for 2 pound ground coffee.  I need to implement it so that it says N-2G or V-2G so that the shipper knows to pack in the specific type of coffee. 

      The current problem lies in here (highlighted in red).  I have an Origin field and it's marked with either an N or a V (for Nicaragua or Veracruz).  I want it to check that if the Origin Field is marked as N, it sets it to "N-".  If it is marked V, then it sets it to "V-".  Right now, it seems to always choose the false condition, no matter what I set the true condition to be.

      Let ( [
      TotalBags = $_total_lbs ;
      LG = $_num_light_ground ;
      LW =  $_num_light_whole ;
      DG = $_num_dark_ground ;
      DW = $_num_dark_whole

      ] ;

      // ship method
      If ( GetAsNumber ( TotalBags ) >2; "U-" ; "E-" )  &

      // origin type
      If ( PatternCount (FULFILL DATES::Origin; "V")  > 0 ; "V-"; "N-")  &

      // light, of there is any
      Case (
      ( GetAsNumber ( LG ) = 0 and GetAsNumber ( LW ) =0 ) ; "" ;
      ( GetAsNumber ( LG ) > 0 and GetAsNumber ( LW ) =0 ) ; "L" & LG & "G-" ;
      ( GetAsNumber ( LG ) = 0 and GetAsNumber ( LW ) >0 ) ; "L" & LW  & "W-";
      ( GetAsNumber ( LG ) > 0 and GetAsNumber ( LW ) >0 ) ; "L" & LG & "G"  & LW & "W" & "-";
      "" ) &

      // dark of there is any
      Case (
      ( GetAsNumber ( DG ) = 0 and GetAsNumber ( DW ) =0 ) ; "" ;
      ( GetAsNumber ( DG ) > 0 and GetAsNumber ( DW ) =0 ) ; "D" & DG & "G";
      ( GetAsNumber ( DG ) = 0 and GetAsNumber ( DW ) >0 ) ; "D" & DW & "W";
      ( GetAsNumber ( DG ) > 0 and GetAsNumber ( DW ) >0 ) ; "D" & DG & "G"  & DW & "W";
      "" )

       )