Skip to Content

Data Type Mismatch

I'm trying to create a formatted search, which includes the following snippet of code:

IF $[ORDR.CardCode] in (select cardcode from ocrd where groupcode = 256 and slpcode = 22) SELECT 'Text String'

When I trigger the FMS, I get the following error

Conversion Failed when converting the nvarchar value 'C12345' to data type int.

In this instance, CardCode translates to 'C12345'. I don't see why it is trying to convert the cardcode to data type int. I don't get an error when I run the code in SSMS (after replacing the field reference with the actual CardCode, of course).

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Aug 11, 2017 at 10:29 PM

    The above snippet is just part of a larger FMS. Here is the entire code:

    --Split Commission Rep
    BEGIN
    IF (SELECT MAX(T0.DiscPrcnt) 
    		from RDR1 T0 
    			inner join ORDR T1 on T1.DocEntry = T0.DocEntry
    		where T1.DocNum = $[ORDR.DocNum])>=70
    	SELECT 'Text 1'
    ELSE
    	IF $[ORDR.CardCode] in (select cardcode from ocrd where groupcode = 256 and slpcode = 22)
    		SELECT 'Text 2'
    ELSE SELECT '' END
    

    The expected result is 'Text 1', 'Text 2' or blank. There error comes from the original code snippet.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 11, 2017 at 10:14 PM

    Hi,

    What is your expected result from above FMS?

    Regards,

    Nagarajan

    Add comment
    10|10000 characters needed characters exceeded