SBX - Search With Button

SBX - Forum Post Title

Content Snippets in Javascript

Microsoft Dynamics CRM Forum

Sahithi P asked a question on 7 Feb 2019 4:48 AM

Question Status

Verified

I have a requirement to show the Terms & Conditions on portal profile page.

So, I have been storing the T&C text in the contact field and showing that content in a modal.

Now, the requirement is to show the T&C based on the preferred language.

I thought of adding the T&C text in content snippets, but I don't have the faintest idea of how to display the content snippets in the javascript.

Can any of you suggest a way to achieve this? Is there any other way instead of:
1. storing the t&c text in a different entity with the language lookup and fetching that information using odata and displaying it in the modal

2. if I were to use content snippets, how would i use them in the script?

Reply
Oliver Rodrigues responded on 7 Feb 2019 7:46 AM
My Badges
Verified Answer

to get a content snippet through JS use the following syntax:

var title = '{{ snippets["YOUR SNIPPET NAME"] }}';

Reply
Sahithi P responded on 4 Apr 2019 4:41 AM

Hi Oliver,

I'm only able to access content snippets from javascript if I write the script on the web page 'Copy(HTML)' or 'Custom Javascript'.

I'm not able to get the content snippets through the javascript code used in the webfiles.

Is there a way to get the content snippet value in the webfiles as well?

Reply
Oliver Rodrigues responded on 4 Apr 2019 5:28 AM
My Badges
Verified Answer

I am actually not using JS files within the Web Files.. for this we need to enable CRM to allow JS as notes attachments, which in my projects I prefer not to

but even though.. I understand you are having a generic JS in the Web Files is that the case? I would imagine the same code should work fine there

Reply
Sahithi P responded on 18 Apr 2019 7:02 AM

I actually used global variable. So, the same code is working.

Thank you.

Reply
Oliver Rodrigues responded on 7 Feb 2019 7:46 AM
My Badges
Verified Answer

to get a content snippet through JS use the following syntax:

var title = '{{ snippets["YOUR SNIPPET NAME"] }}';

Reply
Oliver Rodrigues responded on 4 Apr 2019 5:28 AM
My Badges
Verified Answer

I am actually not using JS files within the Web Files.. for this we need to enable CRM to allow JS as notes attachments, which in my projects I prefer not to

but even though.. I understand you are having a generic JS in the Web Files is that the case? I would imagine the same code should work fine there

Reply

SBX - Two Col Forum

SBX - Migrated JS