locked
MS CRM 2011 - Making an indicator or meter from custom entity with N:N relation RRS feed

  • Question

  • I have a custom entity course which is related to contacts with N:N? Now I need to do chart or some other indicator which tells how many contacts are listed on every course.

    So basicly same with the account and contact where you can calculate employees, but now for the custom entity.

    Any suggestion what is the best and easiest solution to do that?

    Wednesday, July 3, 2013 7:38 AM

Answers

  • As you are putting code in course therefore var Id = Xrm.Page.data.entity.getId();" will give you the id of the course. Now you have to get all contact who has this id in the course field. When we create a relationship the child entity gets an attribute where it holds the id of parent. Same way you will be having a field in contact which has id of course. Instead of contactid put the schema name of that field like

    FetchNumberOfRelatedEntity("contact", "new_COURSECONTACTRELATIONSHIPFIELDNAME");// Replace capital text with actual field name


    Regards Faisal

    • Marked as answer by crm-user-crm Thursday, July 4, 2013 8:08 AM
    Wednesday, July 3, 2013 12:29 PM

All replies

  • You need to count the contacts on a course therefore a ssrs report will meet your requirement.


    Regards Faisal

    • Proposed as answer by ECiftci Wednesday, July 3, 2013 11:30 AM
    Wednesday, July 3, 2013 7:43 AM
  • You need to count the contacts on a course therefore a ssrs report will meet your requirement.


    Regards Faisal

    I am using ONLINE version, so I don't have an access to  ssrs reports I think. Is there any other way to do that?

    Wednesday, July 3, 2013 7:59 AM
  • You can use fetchxml instead of SQL query in online reports. Another option would be to show count of all the child records (contacts) on Parent form (course) using oData.


    Regards Faisal

    Wednesday, July 3, 2013 10:30 AM
  • You can use fetchxml instead of SQL query in online reports. Another option would be to show count of all the child records (contacts) on Parent form (course) using oData.


    Regards Faisal

    Can you provide some example. I am just so learning all these things. I found this some code but I don't know what parameters and things I must change in the code.

    Wednesday, July 3, 2013 10:42 AM
  • This is retreive multiple which is diffrent from oData. You can use this example and call the function on Load of course form like

    FetchNumberOfRelatedEntity("contact", "contactid");

    the scond thing you have to do is change field schema name to the field in which you want to store total in course as under:-

    Xrm.Page.getAttribute("new_PUTSCHEMANAMEHERE").setValue(totalChildren);

    Limitation of oData is that you can retreive 50 records at a time. However we can remove this limitation. Have a look at the following example:-

    http://lakshmanindian.wordpress.com/2012/05/31/retrieve-multiple-using-odata-in-crm-2011/

    You can do the same thing without using any code:-

    http://www.powerobjects.com/blog/2012/01/03/how-to-roll-up-values-from-child-records-to-parent-records-via-workflow-in-microsoft-dynamics-crm/


    Regards Faisal

    • Proposed as answer by Faisal Fiaz Wednesday, July 3, 2013 11:27 AM
    Wednesday, July 3, 2013 11:27 AM
  • This is retreive multiple which is diffrent from oData. You can use this example and call the function on Load of course form like

    FetchNumberOfRelatedEntity("contact", "contactid");

    the scond thing you have to do is change field schema name to the field in which you want to store total in course as under:-

    Xrm.Page.getAttribute("new_PUTSCHEMANAMEHERE").setValue(totalChildren);

    Limitation of oData is that you can retreive 50 records at a time. However we can remove this limitation. Have a look at the following example:-

    http://lakshmanindian.wordpress.com/2012/05/31/retrieve-multiple-using-odata-in-crm-2011/

    You can do the same thing without using any code:-

    http://www.powerobjects.com/blog/2012/01/03/how-to-roll-up-values-from-child-records-to-parent-records-via-workflow-in-microsoft-dynamics-crm/


    Regards FaisalD

    Do I get the correct entityid or in this case contactid with this: "var Id = Xrm.Page.data.entity.getId();"?
    Wednesday, July 3, 2013 11:58 AM
  • As you are putting code in course therefore var Id = Xrm.Page.data.entity.getId();" will give you the id of the course. Now you have to get all contact who has this id in the course field. When we create a relationship the child entity gets an attribute where it holds the id of parent. Same way you will be having a field in contact which has id of course. Instead of contactid put the schema name of that field like

    FetchNumberOfRelatedEntity("contact", "new_COURSECONTACTRELATIONSHIPFIELDNAME");// Replace capital text with actual field name


    Regards Faisal

    • Marked as answer by crm-user-crm Thursday, July 4, 2013 8:08 AM
    Wednesday, July 3, 2013 12:29 PM