tabbey


Hi,

I do not know what I did wrong. I tested a simple function in my custom code and get the error saying "Character is not valid". Any help is appreciated!

Here is the function inside my custom code.

Shared Function test() As string

Dim items As Fields
Return items("DataField1").Value;

End Function

I call the function in the body of my report using: Code.test()

and the error says "There is an error on line 18 of custom code: [BC30037] Character is not valid."

Thanks,

Tabbey




Re: Character is not valid

Vitaliy Kochubiy


Try to remove " ; " after Return items("DataField1").Value





Re: Character is not valid

Andy Potter

Also, you cannot refer to dataset items inside of your Report code block. You must pass values into your function.

Something like this:

Shared Function test(fieldvalue as string) As string
test = fieldvalue

End Function

And then call the function in the body of the report:


=Code.test(ReportItems!DatasetField.Value)








Re: Character is not valid

tabbey

I need to build "fields string" in my custom code depending on the parameters users selected.

If I cannot refer to the dataset items inside the custom code, can you think of any other alternative solution

I construct the fields string in textbox expression, but I get an error if the field did not exist since IIF evaluate the entire expression.

Thanks,

Tabbey





Re: Character is not valid

Andy Potter

Can you create a function with a signature that accepts all the fields you wish to concatenate

Function addString (field1 as string, field2 as string, field3 as string) as String
if Parameter!UserInput.Value = true then
addString = field1 & field2 & field3
End Function

You could always create a custom data processing extension and handle it there. you could also probably handle this in the logic of your stored procedure.





Re: Character is not valid

tabbey

Andy,

That sounds like a good idea. Let me try that out. Thanks!