2 Replies Latest reply on Jun 22, 2011 12:09 PM by Marcos J Pinto

    String concat in webservice

    Marcos J Pinto Level 1



      I've created a webservice that reads a value from a database using this SQL statement:


      SELECT ID from sequencias WHERE ( ref = {$ /process_data/@refFormulario$});


      This just returns a number (in a string output variable) to the form.


      Now I need to concatenate a slash and the current year. So if the the number is, say, 345, I need to add "/2011".


      Question: should I add another Task or is there a way of using a string function (like Concat) to do this?


      And... how do I do it? I've tried to use concat when building the Data mapping, but it did not work.


      Thank you for any hints!



        • 1. Re: String concat in webservice
          $Nith$ Level 4

          Option1 :

          You can concatenate this string in the SQL statement itself which is faster than any other options below.


          Query (for Microsoft Sql Server database)


          SELECT CONVERT(VARCHAR,ID)+'/'+CONVERT(VARCHAR,DATEPART(YEAR,GETDATE())) as ID from sequencias WHERE ( ref = {$ /process_data/@refFormulario$});


          Query (for MySql database)


          SELECT CONCAT( ID, '/' YEAR (NOW()) ) as ID from sequencias WHERE ( ref = {$ /process_data/@refFormulario$});




          Option 2:

          Concatenate the result string from web service using a SetValue activity at the end of web service workflow.



          /process_data/@result = concat(/process_data/@result, "/", get-year-from-date(current-date()))

          Assuming that the output variable name is "result"


          Option 3:

          After the data gets populated in the form field, you can change through either JavaScript or FormCalc.




          • 2. Re: String concat in webservice
            Marcos J Pinto Level 1

            Hey Nith!


            Thank you very much, once again!


            I used the Workbench solution, worked perfectly!


            Thank you!