velocitysap-commerce-cloudhybris-data-hub

Fetch organization name from FormRowModels


Previously I was using separate email context for different subjects and I was doing something like this.

enter image description here

Now I want to fetch organization name from VM file only from formRowModels but this is giving an error.

${ctx.formRowModels.stream().filter(row -> row.getKey().contains("Organization"))}

enter image description here


Solution

  • This is because when you're writing code in a VM file, you're not using Java but VTL (Velocity Template Language). You need to filter the desired value using a combination of #foreach & #if #else directives.

    Example:

    #foreach ($row in $ctx.yourList)
        #if ($row ... )
         doSomethingHere 
        #end
    #end