[OfficeUtils] How to generate a custom mapping list without using dozens of (single) ListAppends?
officeutils
Service icon
Forge component by Bruno Gonçalves
Application Type
Reactive
Service Studio Version
11.53.14 (Build 61220)

Hello there,

I am using the OfficeUtils extension to populate a word template with variables. Therefore I need to create a mapping list containing the name of the placeholder and the variable that needs to fill this placeholder. So that I can cycle through this list to replace the placeholder within the word template with the mapped variable (the OfficeUtils function "Word_Export_Set_Text" can only replace one placeholder per call).

My current solution is to create local variable ("CV Mapping"). This variable is typed as a list of a structure containing two attributes (Placeholder and Text). With this solution I have to use the built-in Server Action "ListAppend" for each of the placeholder-text combination that I need.

Instead of repeatedly adding "ListAppend" is there a way to populate this list in one go using just one expression (and providing the desired list in kind of a json format)? I read that you can use "ListAppendAll" and writing the needed list within an expression of the source list, but I could not make this working...

Thanks for your help :)

Bildschirmfoto 2022-08-28 um 13.34.59.png

Hi Konsti,

I'm not sure what you mean with 'in kind of a json format', but I'll just answer the question about using one ListAppendAll instead of multiple ListAppend nodes.

So the only trick to this, is finding the + symbols, which only appear when you hover over the right spot.

For every row you want in your list, you choose the plus sign next to SourceList :

And then, if it is not a list of a basic data type, on each row you add, you still need to choose the plus sign next to that row to open it up and fill in the variables.

Dorine

Hi Dorine,


thank you for your quick response. Yeah I also discovered this option randomly a few hours ago. 

What I was thinking about is writing an expression into the „SourceList“ field. And within this expression I want to provide a list:

[{placeholder: „name“, text: User.Name}, {placeholder: „email“, text: User.Email}, …]

So is it possible to manually create the data for such a list within an expression?

Thanks & best,

Konsti

A list and Json are not the same thing, but can be converted into each other.

So i suppose you could squeeze everything in one single expression making the Json, and then do a JsonToRecordList, but I don't see the point, it would only make your code less readable and maintainable, I think.

Often, I see people coming from other programming background to have a distinct preference for doing as much as possible inside expressions instead of using multiple visual nodes to do the same thing.  And allthough I also like my code to be concise, OS is a visual language, so I try to embrace that.  Putting lots of stuff inside nodes, makes the flow less readable.

Dorine

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.