There is a syntax error..

yuppicideyuppicide Member Posts: 410
edited 2012-03-09 in Navision Attain
Sorry to re-open an old topic. I had a post here:

viewtopic.php?f=14&t=48690

But wanted to post fresh to draw attention.

You guys helped me add some code that prints on my Sales Invoice based on letter of the alphabet for Sell To customer. The phone numbers/alphabet letters had changed, thus I changed them.

FOr awhile they only had 4 people working there, so I didn't need the part about getting the second letter for S. Now they've got a 5th person working, so I need to add it back and am getting "There is a Syntax error."

N-SK goes to one person's phone, SL-Z goes to another.

What am I doing wrong?
IF "Payment Terms Code" = 'NET+30F' THEN BEGIN
  RemitText1 := 'xxxxxxxxxxxx:';
  RemitText3 := 'xxx xxxxxxxxxxx';
  RemitText4 := 'xx xxxxxxx';
  RemitText5 := 'xxxxxx xxxxxxx';
  RemitText6 := 'xxxxxxxx, xx xxxxx';
  RemitText7 := 'THIS ACCOUNT AND ALL THE MERCHANDISE CONSTITUTING THE SAME HAVE BEEN ASSIGNED AND ARE';
  RemitText8 := 'OWNED BY, AND PAYABLE EXCLUSIVELY TO xxxxxxxxxxxxxxxxxxxx. IF INCORRECT, IN';
  RemitText9 := 'ANY PARTICULAR, COMMUNICATE DIRECTLY TO xxxxxxxxxxxxxxxxxxx.';
    RepMarker := COPYSTR("Sell-to Customer Name",1,1);//Gets the first character
      IF RepMarker IN ['0','1'] THEN RemitText10 := 'CONTACT xxxxxxxxxxxxxxxx AT: (###)-###-####.';
      IF RepMarker IN ['2','3'] THEN RemitText10 := 'CONTACT xxxxxxxxxxxxxxxx AT: (###)-###-####.';
      IF RepMarker IN ['4','5'] THEN RemitText10 := 'CONTACT xxxxxxxxxxxxxxxx AT: (###)-###-####.';
      IF RepMarker IN ['6','7'] THEN RemitText10 := 'CONTACT xxxxxxxxxxxxxxxx AT: (###)-###-####.';
      IF RepMarker IN ['8','9'] THEN RemitText10 := 'CONTACT xxxxxxxxxxxxxxxx AT: (###)-###-####.';
      IF RepMarker IN ['A','B','C'] THEN RemitText10 := 'CONTACT xxxxxxxxxxxxxxxx AT: (###)-###-####.';
      IF RepMarker IN ['D','E','F','G','H'] THEN RemitText10 := 'CONTACT xxxxxxxxxxxxxxxx AT: (###)-###-####.';
      IF RepMarker IN ['I','J','K','L','M'] THEN RemitText10 := 'CONTACT xxxxxxxxxxxxxxxx AT: (###)-###-####.';
      IF RepMarker IN ['N','O','P','Q','R'] THEN RemitText10 := 'CONTACT xxxxxxxxxxxxxxxx AT: (###)-###-####.';
      IF RepMarker IN ['T','U','V','W','X','Y','Z'] THEN RemitText10 := 'CONTACT xxxxxxxxxxxxxxxx AT: (###)-###-####.';
    	        IF RepMarker = 'S' then begin
	          Repmarker := COPYSTR("Sell-to Customer name",2,1); //gets second char
        	IF Repmarker in ['A','B','C','D','E','F','G','H','I','J','K'] then REMITTEXT10 := '(###)-###-####';
        	IF Repmarker in ['L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] then REMITTEXT10 := '(###)-###-####';
 END;

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I count 2 BEGIN's, but only 1 END-statement ...
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • yuppicideyuppicide Member Posts: 410
    I will try it again. I had tried putting another END; in there but got the same message.
  • yuppicideyuppicide Member Posts: 410
    Yeah, not working. I tried putting the end at the end.. ie:

    END;
    END;

    I also tried putting it in the middle somewhere.
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    yuppicide wrote:
    I also tried putting it in the middle somewhere.
    You are not playing at the lottery here, you are developing a Dynamics NAV application [-X

    I can get your code to compile, by putting the END-statement at some place. If your code is working is a different story, I can't resolve that.

    Maybe you have some additional code which you don't show, or have the variables declared wrong.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • SavatageSavatage Member Posts: 7,142
    edited 2012-03-07
    looks like it belongs at the end.

    You can also use // to comment out some lines to see if it complies and remove one at a time until you find the offending line. You could be missing a quote or misspelled a variable.

    Note: I see you are not using the View->Globals->Text Constants.
    It might help you clean that code up.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    yuppicide wrote:
    Yeah, not working. I tried putting the end at the end.. ie:

    END;
    END;

    I also tried putting it in the middle somewhere.

    :mrgreen: That got me laughing (sorry).
    David Singleton
  • SavatageSavatage Member Posts: 7,142
    edited 2012-03-07
    your last lines of
    IF Repmarker in then REMITTEXT10 := '(###)-###-####';
    IF Repmarker in then REMITTEXT10 := '(###)-###-####';

    how about since if it's not a thru k then it has to be the other choice of phone#'s
    IF Repmarker in
    then REMITTEXT10 := '(###)-###-####' //one thing
    else REMITTEXT10 := '(###)-###-####'; //other thing
  • David_SingletonDavid_Singleton Member Posts: 5,479
    This thread and the one it links to are wrong on way to many levels.

    Create a new table, Code and Contact No.

    Link this to a field in the Customer card Collections Contact
    create a batch to update the records on the customer card as appropriate, either manually enter filters and run multiple times, or add from customer and to customer into the Collection Contact table.

    Sometimes you can go so far down the wrong path that you can no longer see the light. At that point turn around and start again.
    David Singleton
  • SavatageSavatage Member Posts: 7,142
    You can also be on an old version where you no longer have support and you don't have a license to do it what it really calls for - so a workaround is your only option. This sounds like their case.
  • SavatageSavatage Member Posts: 7,142
    I still don't get the whole different Rep based on the first for 2nd character of the Sell-to Customer Name but to each his own.
    Isn't that what the salesperson code is for?

    If reps & salespeople are different in your company and you need an easy way to assign them to a customer - you can add you reps in the salesperson table and add a new field to the customer table calles Sales Rep or whatever. And use Salesperson/Purchaser as TableRelation for your new field so you can pull up the rep values also in a seperate field.

    Then all that text would be saved in the Salesperson/Purchaser and you can just call upon it depending on the rep code per customer and any new rep won't cause you such headaches changing code & text & phone numbers based on a character. It would just work. and perhaps if you ever change how reps work in your biz all you have to do is update the customer "Sales Rep" field.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Savatage wrote:
    I still don't get the whole different Rep based on the first for 2nd character of the Sell-to Customer Name but to each his own.
    Isn't that what the salesperson code is for?

    If reps & salespeople are different in your company and you need an easy way to assign them to a customer - you can add you reps in the salesperson table and add a new field to the customer table calles Sales Rep or whatever. And use Salesperson/Purchaser as TableRelation for your new field so you can pull up the rep values also in a seperate field.

    Then all that text would be saved in the Salesperson/Purchaser and you can just call upon it depending on the rep code per customer and any new rep won't cause you such headaches changing code & text & phone numbers based on a character. It would just work. and perhaps if you ever change how reps work in your biz all you have to do is update the customer "Sales Rep" field.

    :thumbsup:

    See now that is a proper solution, even if they don't have access to a spare table. Basically take my idea and merge it with yours and they don't need this horrible if then in else nonsense.
    David Singleton
  • SavatageSavatage Member Posts: 7,142
    The salesperson/Purchaser table is very basic Code, Phone Number, Email...

    You can add new fields to that table like
    Address
    Address 2
    City
    State
    Zip
    Country
    Fax#
    Mobile#
    Extention

    Makes it very easy to store all the info you need on certain people in your company if New tabels are in tight supply.

    you can add the "Sales Rep" field to the sale order (for 1 Get) or Call back on it in your report (with 2 gets) like
    Customer.Get(SalesHeader."Sell-to Customer No.") //get access to customer table info
    "Salesperson-Purchaser".Get(Customer."Rep Code") //get access to salesperson/purchaser info.

    With if's n'such to battle off crashes.

    then all that text would simply be fields from the sales/purch table that can be easily managed and changed if needed. You can do it in steps. Keep your old way until you are ready to change.

    Add all the necessary fields to hold your rep info.
    Add Your rep info.
    add your new customer table field.
    assign a rep code to each customer. //easy with find & replace or processing report
    once all that's done you can work on the report.
  • yuppicideyuppicide Member Posts: 410
    No, we do have Salesrep. That's fine.

    Then I was asked to add some data to a Posted Sales Invoice.. so based on the Terms it will print where they should send their payment.

    For example, Credit Card would say "Your order has already been paid by credit card. Thanks!"

    But for people who are on credit terms, like Net 30 (where they have to pay within 30 days), or Net 60 (pay within 60 days) through an outside company, I needed to write where they need to make the payments and the contact phone numbers. The phones numbers changed every so often.

    Probably based on what access I have I probably had to do it this way.

    So companies who begin with A-C call one number, D-H call 212 another, I-M call another, N-SK call another, and SL-Z call another.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    yuppicide wrote:
    Probably based on what access I have I probably had to do it this way.

    No that is absolutely NOT true. ](*,) You were given a solution but for some reason chose to ignore it. :thumbsdown:
    David Singleton
  • SavatageSavatage Member Posts: 7,142
    Perhaps he's not understanding.

    Ok so let's not call it sales reps. Perhaps "Payment Contact" is a better name.

    I was just suggesting that you can use the same table as "salesperson/purchaser" to store your (current) five different Payment Contacts if you didn't have a table available. Just by making a new field on the customer Table "Payment Contact" or "Sales Rep" (whatever makes sence to you) and using "Salesperson/Purchaser" as the table relation, you will be able to assign values to this field with a lookup.

    Then based upon the customer name & payment terms you assign one of these contacts on their customer card. Should be easy by filtering the name and using find & replace to fill the values in the field. When you print an invoice it can check the customer card to see which contact info it should print.
    *As a bonus you now have a field you can use for reporting

    This will allow you to easily update any contact info in one place and add/remove any contacts if you need to. If done this way there will be need for future code changes.

    So instead of entering all that TEXT & IF's in the report, it would pull the name, address, phone, etc info right from the table.

    Since you need this in a report - no special developer license needed as long as you can add some custom fields. which from other posts I gathered isn't an issue for you.

    PS: did you ever figure out the cause of your syntax error (missing end;)?
Sign In or Register to comment.