Append to text doc from template smartservice

Certified Associate Developer

Hello Community,

U want to use a array of CDT's as input to the text from template smartservice. It works fine for 1 Line. How to configure the next CDT's Will append to the document on the next Line? Tried joinarray char 13 and char 10, this only works for one mergefield.

Kind regards,

Erik

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    As far as I know, you should be able to insert char(10) linebreaks into a text-from-template document and get linebreaks in the resulting text document.  If you have a dynamic number of rows you want to generate in the document, you would probably need to use one merge field and use an expression rule to handle generating the text that you want to populate into it.

  • 0
    Certified Associate Developer
    in reply to Mike Schmitt

    Okay that option crossed my mind, but thought maybe there is another solution.

    Thanks for your help Mike.

    Kind regards,

    Erik

  • 0
    Certified Lead Developer
    in reply to erikb0001

    I did that a while ago. You have a placeholder in the file. When inserting, just add that same placeholder at the end. Appian will replace it happily in the next iteration.

  • 0
    Certified Associate Developer
    in reply to Stefan Helzle

    Hello Stefan,

    I got it working by implementing the one merge field solution concat al the data in one string and then passing it as single value variable using joinarray char(13) char(10). But would like to know how you used the place holder at the end. Maybe later then can compare the performance of both solutions.

    can you explain with a simple example if the template consist of three merge fields like: 

    ###customerFirstName### ###customerLastName### ###birthDate###.
    The pv's are multi values.

    Then do you mean :

    ###customerFirstName### ###customerLastName### ###birthDate### ###placeHolder###.

    placeHolder value: char(13) char(10)

    Kind Regards,

    Erik

  • 0
    Certified Lead Developer
    in reply to erikb0001

    My file looked like this while going through the iterations:

    ###content###

    ---------------------

    agsfkgsahfksgafhsag

    ###content###

    --------------------------

    ashdjkhsfjsfhjkshfjska

    sahjflhsshfjshfjsakfhajs

    ###content###

    This was a process loop. At the end of the loop I made a last update to the file replacing the placeholder with an empty string. If you have more placeholders, then just add these after each insert.

    Whether that fits your use case is up to you.

    If your data volume is small I would go with an expression that just creates a line of text for each item and does a joinarray(local!lines, char(10) and/or char(13) for the Windows world).

  • 0
    Certified Associate Developer
    in reply to Stefan Helzle

    Thank you Stefan,

    The volume is small, and the line of text for each items works, so guess I keep that.

    Kind Regards,

    Erik

  • 0
    Certified Senior Developer
    in reply to erikb0001

    hi team,
    I have similar requirement where am trying to write the CDT to document using text doc from template SS, but am facing below issue:
    1) As it is a multiple value CDT am trying to pass same in a single value in template as ###data### using joinarray(CDT,char(13),char(10)) but in the output I have this

    [name=jhdh, place=hjhjfhj, date=24/01/2020, address=hdfhjfd]

    [name=erec, place=qwerf, date=24/02/2020, address=nbhd]

    [name=fghc, place=xcsdf, date=24/03/2020, address=dfgre]

    [name=dfs, place=cvbgf, date=24/05/2020, address=qwqwqe]

    [name=xxxx, place=rertt, date=24/01/2020, address=sdwess]

    in the output I dont want column names , how can i eliminate it?
    secondly I want each column to be pipe ("|") separated how can i achieve that here  

    Thanks in advance for your valuable input.

    regards 

  • 0
    Certified Lead Developer
    in reply to Preji P

    In this case, you use a foreach to first format each item into a line of text with whatever format you prefer. Then you append that list to the existing content.

Reply Children
No Data