Skip to content
+1-888-319-3663

COMMUNITY FORUM

COMBINING 2 FIELDS TO MAKE ONE

Sarah asked 5 years ago
I have a smartlist that I want to combine 2 fields and make one.  For Example
I want combine Customer Number and Address Code so that they be come one Code (SFGP CODE) with a space
Customer Number = ABGR0001
Address Code = Main
SFGP Code = ABGR0001 MAIN
I keep getting errors when trying to validate the calculation. Can someone please help me with the correct wording?
Answers
Patrick Roth Staff answered 5 years ago
Sarah,
is should be as simple as just adding the fields together (assuming VB vs C# code)
return _CUSTOMERNUMBER + ” ” + _ADDRESSCODE
or
return _CUSTOMERNUMBER & ” ” & _ADDRESSCODE
My guess is that the validation is probably for other code you have on the map.  When you press Validate, it validates all the code in the map – not just the current code piece.
When you press Validate, it should then give you all the errors and in that dialog it’ll tell you the method that has the actual error as well. 
 
 
 
Sarah Case replied 5 years ago

Hi Pat,
This is actually the only calculation I currently have set up in this report and when I put in both of the lines you gave me above I get an error that says: There is an error in the calculated field. [Micorsoft][SQL Server Native Vlient 10.0][SQL Server]Incorrect syntax near the keyword ‘return’.

Nicole Albertson Staff answered 4 years ago
Sarah,
 
I apologize for the delay as I just came upon this today when looking for something else.  It appears that Pat was answering the question as if you were using SmartConnect, not SmartList Builder.  I apologize for that. 
 
In SmartList Builder, you can create the calculation something like this.
RTRIM ( {RM Customer MSTR:Customer Number} ) + ‘ ‘ + RTRIM ( {RM Customer MSTR:Address Code} )
 
I use the RTRIM functions around each field to remove the trailing spaces on the fields and then add one in the middle between the two fields with the apostrophes around the space.
Let me know if you have any further questions on this or it doesn’t work.  I was not sure which table you were using, so you may need to edit it a little bit.
 
Thanks,
Nicole

If you would like to submit an answer or comment, please sign in to the eOne portal.