Closed andreaPorini closed 4 years ago
Hi @andreaPorini,
sure, when is this problem occuring? Seems like it is receiving an entity reference when it is expecting a string.
Kind Regards, Florian
Thank you Florian,
i've configured my step like this:
It triggers when I update the HTML Template lookup field, writing the rendered template into the "renderedtemplate" field.
The template il very basic, one textbox with ${{Value ("prn_code")}}, nothing more.
When i update and the execution criteria returns "true", i get the exception I wrote before.
Thanks again, Andrea
Hi @andreaPorini,
found the issue. The template field is for per-record templating, for example when you have a source field in your entity which contains the template text already instead of a global one. If you want to pull the template from a HTML template, please clear the template field input and write in the lower global template input:
${{Value("prn_htmltemplateid.oss_html")}}
Kind Regards, Florian
Hi @DigitalFlow ,
ok with this workaround I do not get the exception but the template is not correctly parsed.
As I said, my sample template now contains only "${{Value ("prn_code")}}", with your workaround i get the template but in my target field I find the template with "${{Value ("prn_code")}}" printed in and not the code I expected to see.
Seems like the template is "parsed" only for the first time, fetching the content.
Do you have any idea to solve this?
Best regards, Andrea
Hi @andreaPorini,
yes, there's always two steps required for this scenario: one for injecting the template and one for applying it. When you inspect the SDK steps which are shipped with Xrm-Html-Templating, you will see that there are also always two steps: One for inserting and one for applying it.
You would now need a second step on the same message, which runs on rank 2 and which has prn_renderedtemplate
as target field and now also as template field (the one which you set in the beginning).
On this second iteration, XTL will get the raw template that we inserted, apply it and write the result back to the same field.
Kind Regards, Florian
Ok I understand the process, but, if I remember well, in the example you use in your other repo HTML templating tool (https://xrmadventuretime.com/tutorials/html-e-mails-with-place-holders-in-dynamics-365/) you use the same method I used initially to insert the template in an Email description field, why in this case the process is different?
I have both solutions installed in my CRM instance.
Thank you for your responses and you're patience, Andrea
Hi @andreaPorini,
good that you ask.
I forgot that I created a patch at some point, that you could call functions inside the per record templating as well.
Can you try to clear the lower global template field again and use this in the upper per-record template input:
Value("prn_htmltemplateid.oss_html")
The plugin should recognize that the per-record template input is not a plain field and try to execute it, so one step should suffice like that.
Kind Regards, Florian
Hi @DigitalFlow,
that's it! Perfect, this way the plugin is working correctly.
As always, thank you for your assistance and for this awesome addon!
Best regards, Andrea
Hi @andreaPorini,
awesome! :) I'm glad that you like it 👍
Kind Regards, Florian
Hi @DigitalFlow,
I found an error during the execution of the plugin, seems like there is a mismatch of types during the configuration retrieve.
This is the StackTrace of the error:
` Unhandled exception: Exception type: System.ServiceModel.FaultException'1[Microsoft.Xrm.Sdk.OrganizationServiceFault] Message: An unexpected error occurred from ISV code. (ErrorType = ClientError) Unexpected exception from plug-in (Execute): Xrm.Oss.XTL.Templating.XTLProcessor: System.InvalidCastException: Unable to cast object of type 'Microsoft.Xrm.Sdk.EntityReference' to type 'System.String'.Detail:
`
Can you help me identifyng what's wrong?
Best regards, Andrea