Convert Code to Integer

2»

Comments

  • idiotidiot Member Posts: 651
    awarn wrote:
    What version are you on?

    FINDFIRST will only work from 4.0 SP3 and up, if you are using earlier then use FIND('-') instead of FINDFIRST

    -a
    FINDFIRST works in 4.0 SP1 & above, not sure about 4.0 without SP
    NAV - Norton Anti Virus

    ERP Consultant (not just Navision) & Navision challenger
  • NASiNASi Member Posts: 48
    Hi DarkHorse:
    Try a REPEAT / UNTIL Next=0 after FIND('-')
    Thanks a lot.
  • DarkHorseDarkHorse Member Posts: 389
    Thanks for reply, but the result is the same; it always shows me the message "must send interaction 3"m, even if I did it. This is the code.
    Thanls in advance for help.

    interaccion.INIT;
    interaccion.RESET;
    interaccion.SETCURRENTKEY("Contact No.","Correspondence Type","E-Mail Logged",Subject);
    interaccion.SETRANGE("Contact No.",Cont."No.");
    IF interaccion.FIND('-') THEN BEGIN
    REPEAT IF interaccion."Interaction Template Code" = '3' THEN
    CreateCustomer(ChooseCustomerTemplate)
    ELSE
    ERROR(must send interaction 3');
    UNTIL interaccion.NEXT=0;
    END;
  • sunctsunct Member Posts: 72
    Try this -

    interaccion.INIT;
    interaccion.RESET;
    interaccion.SETCURRENTKEY("Contact No.","Correspondence Type","E-Mail Logged",Subject);
    interaccion.SETRANGE("Contact No.",Cont."No.");
    interaccion.SETFILTER("Interaction Template Code",'%1',3);

    IF interaccion.FIND('-') THEN BEGIN
    CreateCustomer(ChooseCustomerTemplate)
    ELSE
    ERROR(must send interaction 3');
    END;
    Regards,
    Sunil
  • DarkHorseDarkHorse Member Posts: 389
    Thank you very much, but it stops in interaccion.SETFILTER("Interaction Template Code",'%1',3); saying that is impossible to do the conversion Code:Integer and I can't save it.
    Thanks for help.
  • DenSterDenSter Member Posts: 8,305
    Either:
    interaccion.SETFILTER("Interaction Template Code",'%1',FORMAT(3));
    // FORMAT translates any variable into a text string
    
    or
    interaccion.SETFILTER("Interaction Template Code",'%1','3');
    // the '' will make it so NAV interprets it as a text string
    
    or
    interaccion.SETRANGE("Interaction Template Code",3);
    // SETRANGE converts types automatically
    
  • DarkHorseDarkHorse Member Posts: 389
    Thanks for reply and for explanation. I know that i'm turning tiresome, I'm sorry.
    If I put interaccion.SETFILTER("Interaction Template Code",'%1',FORMAT(3)); it says me that on ELSE instruction should be the END instruction; I'm trying put it but I can't find the way.
    Thanks.
  • sunctsunct Member Posts: 72
    IF interaccion.FIND('-') THEN BEGIN
    CreateCustomer(ChooseCustomerTemplate)
    ELSE
    ERROR(must send interaction 3') //remove semicolon
    END;
    Regards,
    Sunil
  • DarkHorseDarkHorse Member Posts: 389
    Thanks, but it is removed, the code follows as this:

    interaccion.INIT;
    interaccion.RESET;
    interaccion.SETCURRENTKEY("Contact No.","Correspondence Type","E-Mail Logged",Subject);
    interaccion.SETRANGE("Contact No.",Cont."No.");
    interaccion.SETFILTER("Interaction Template Code",'1%',FORMAT(3));
    IF interaccion.FIND('-') THEN BEGIN
    CreateCustomer(ChooseCustomerTemplate)
    ELSE
    ERROR('must send interaction 3')
    END;
  • sunctsunct Member Posts: 72
    Is it giving error?
    Regards,
    Sunil
  • awarnawarn Member Posts: 261
    Indent your code to find out where to put the BEGIN and END (in this case not needed).

    interaccion.INIT;
    interaccion.RESET;
    interaccion.SETCURRENTKEY("Contact No.","Correspondence Type","E-Mail Logged",Subject);
    interaccion.SETRANGE("Contact No.",Cont."No.");
    interaccion.SETFILTER("Interaction Template Code",'1%',FORMAT(3));
    IF interaccion.FIND('-') THEN
    CreateCustomer(ChooseCustomerTemplate) //no semicolon
    ELSE
    ERROR('must send interaction 3'); //semicolon to end the IF line
  • DarkHorseDarkHorse Member Posts: 389
    I'm sorry, now it works correct, but it goes on show me the message "must send interaction 3" even if I did it. It's a madness, I don't know what's the problem.
    Thanks everybody for help.
  • sunctsunct Member Posts: 72
    are you sure the interaction template code with value 3 exists in the table?
    Regards,
    Sunil
  • DenSterDenSter Member Posts: 8,305
    Any time that you do a BEGIN, you must match it with an END.
    IF interaccion.FIND('-') THEN BEGIN 
      CreateCustomer(ChooseCustomerTemplate)
    ELSE
      ERROR('must send interaction 3')
    END;
    
    There is no END to mark the end of the TRUE leg of your IF statement. Try this:
    IF interaccion.FIND('-') THEN BEGIN 
      CreateCustomer(ChooseCustomerTemplate);
    END ELSE BEGIN
      ERROR('must send interaction 3');
    END;
    
    Note that in the middle I replaced "ELSE" by "END ELSE BEGIN". Maybe for your eyes it makes more sense like this:
    IF interaccion.FIND('-') THEN 
      BEGIN 
        CreateCustomer(ChooseCustomerTemplate);
      END;
    ELSE
      BEGIN
        ERROR('must send interaction 3');
      END;
    
    Don't forget to add a semicolon ( ; ) at the end of each complete statement.
  • DenSterDenSter Member Posts: 8,305
    sunct wrote:
    IF interaccion.FIND('-') THEN BEGIN
    CreateCustomer(ChooseCustomerTemplate)
    ELSE
    ERROR(must send interaction 3') //remove semicolon
    END;
    You're missing an END in the middle there.
  • sunctsunct Member Posts: 72
    That Begin is not required there :(
    Regards,
    Sunil
  • DenSterDenSter Member Posts: 8,305
    But you put it there, so then you have to match it with an END. Every BEGIN must have a matching END. Either you remove the BEGIN at the start of the code as well as the END at the end of the code, or you add END and another BEGIN in the middle.

    So either:
    IF interaccion.FIND('-') THEN BEGIN 
      CreateCustomer(ChooseCustomerTemplate);
    END ELSE BEGIN
      ERROR(must send interaction 3');
    END;
    
    or
    IF interaccion.FIND('-') THEN
      CreateCustomer(ChooseCustomerTemplate) 
    ELSE 
      ERROR(must send interaction 3');
    
    Personally I like the first one, because then you can add code without having to think about BEGIN and END statements.
  • DarkHorseDarkHorse Member Posts: 389
    Thanks everybody for help. Aswering your questions interaction 3 exist. I've tried all the convinations and the result always is the same, it always shows me the message "you must send interaction 3" even if I did it. I don't know what more can I do.
    Thanks sincerely for help.
  • awarnawarn Member Posts: 261
    The real question is, does interaction 3 exist for that particular contact. the code is saying no :(
  • DarkHorseDarkHorse Member Posts: 389
    Yes, I know it's strange, but by all means exist for that contact. If sameone is interest I can send the screen captures.
    Thanks for reply.
Sign In or Register to comment.