Answered by:
Customer Portal Product Registration Restriction

Question
-
Hi,
After installing the Customer Portal I noticed that when a user customer goes to register a product all the products from Dynamics CRM are exposed which could be thousands in some instanaces.
Is there a way to select in Dynamics CRM to which products are publishd to the Customer Portal for registration.
So for example restric all products being published and select a tick box like in the case of the Knowlege base solulion that will activate publishing the products? Or any other similar solution.
Thanks in Advance.
Abby_Doc
Friday, June 24, 2011 5:31 AM
Answers
-
This modification requires some basic CRM customizations, re-generating your xrm.cs file, and making appropriate changes to your code based on the other two example pages I gave. I am not comfortable in setting the expectation that a non-developer can just copy/paste the code and it magically start working. The problem is not difficult, but I would recommend that a developer make the modifications.
The KB article code your developer should look at is:
var kbarticles = XrmContext.KbArticleSet.Where(k => k.StateCode == (int)Enums.KbArticleState.Published && k.msa_publishtoweb == true);
- notice that it is filtering by a custom attribute msa_publishtoweb. That attribute was added to the knowledge base article entity in CRM as part of the portal solution.
The notes on a case are filtered by a string variable. The case notes are rendered with a LinqDataSource which is a different mechanism than the static binding for a generic search for KB articles. Here is the code for the cases that does the filtering:
<asp:LinqDataSource ID="CrmNoteSource" runat="server" ContextTypeName="Xrm.XrmServiceContext" TableName="AnnotationSet" Where="ObjectId.Id == @CaseID && NoteText.Contains(@Filter)" OrderBy="CreatedOn DESC" OnSelecting="LinqDataSourceSelecting"> <WhereParameters> <asp:QueryStringParameter Name="CaseID" QueryStringField="CaseID" DefaultValue="00000000-0000-0000-0000-000000000000" DbType="Guid" /> </WhereParameters> </asp:LinqDataSource>
The filter parameter is set in the code behind as follows:
var parameter = new Parameter("Filter", DbType.String, "*WEB*");
Shan McArthur www.shanmcarthur.net Check out the commercial edition of xRM portals @ www.adxstudio.com- Marked as answer by Abby_Doc Tuesday, August 23, 2011 4:08 AM
Friday, July 1, 2011 12:42 AMModerator
All replies
-
There are two examples of different approaches already in the portals. The case notes filter by using *web* in the note title, and the KB article search uses a field to define whether or not it is visible in the portal. You need to determine *how* you want to filter this, then simply update the code in the portal to filter it based on the approach that you want to take.
Shan McArthur www.shanmcarthur.net Check out the commercial edition of xRM portals @ www.adxstudio.comSaturday, June 25, 2011 6:26 PMModerator -
Hi Shan,
Thanks for the reply.
May I ask which code snippets to copy and where to add it in the code?
Regards,
Abby_Doc
Sunday, June 26, 2011 12:27 AM -
This modification requires some basic CRM customizations, re-generating your xrm.cs file, and making appropriate changes to your code based on the other two example pages I gave. I am not comfortable in setting the expectation that a non-developer can just copy/paste the code and it magically start working. The problem is not difficult, but I would recommend that a developer make the modifications.
The KB article code your developer should look at is:
var kbarticles = XrmContext.KbArticleSet.Where(k => k.StateCode == (int)Enums.KbArticleState.Published && k.msa_publishtoweb == true);
- notice that it is filtering by a custom attribute msa_publishtoweb. That attribute was added to the knowledge base article entity in CRM as part of the portal solution.
The notes on a case are filtered by a string variable. The case notes are rendered with a LinqDataSource which is a different mechanism than the static binding for a generic search for KB articles. Here is the code for the cases that does the filtering:
<asp:LinqDataSource ID="CrmNoteSource" runat="server" ContextTypeName="Xrm.XrmServiceContext" TableName="AnnotationSet" Where="ObjectId.Id == @CaseID && NoteText.Contains(@Filter)" OrderBy="CreatedOn DESC" OnSelecting="LinqDataSourceSelecting"> <WhereParameters> <asp:QueryStringParameter Name="CaseID" QueryStringField="CaseID" DefaultValue="00000000-0000-0000-0000-000000000000" DbType="Guid" /> </WhereParameters> </asp:LinqDataSource>
The filter parameter is set in the code behind as follows:
var parameter = new Parameter("Filter", DbType.String, "*WEB*");
Shan McArthur www.shanmcarthur.net Check out the commercial edition of xRM portals @ www.adxstudio.com- Marked as answer by Abby_Doc Tuesday, August 23, 2011 4:08 AM
Friday, July 1, 2011 12:42 AMModerator