locked
Retrieve the sub grid values based on the condition CRM 2013 Java script RRS feed

  • Question

  • Hi All,

    I am able retrieving the sub grid cell value with YES or NO Conditions. 

    Sub Grid have more than 5 records. 

    Some records claim history has Yes and some records Claim History  Record is NO.

    if Sub gird records few of them has YES and Few of them has No i have set the different option set value. I am not able to set the array or ArryList . Please suggest it below code

    function RetrieveSubGridRecords() {
        var Hasclaimed;
        if (document.getElementById("mc_policymembers")) {
            var grid = document.getElementById("mcsuk_policymembers").control;
            for (var rowNo = 0; rowNo < grid.GetRecordsFromInnerGrid().length; rowNo++)
                Hasclaimed = grid.GetRecordsFromInnerGrid()[rowNo][3].cells[3].outerText;
        }
        else {
            setTimeout("RetrieveSubGridRecords();", 2500);
        }
        
        if (Hasclaimed == "No") {
            Xrm.Page.getAttribute('mc_hospitalclaim').setValue(110090000);
        }
        else if (Hasclaimed == "Yes") {
            Xrm.Page.getAttribute('mc_hospitalclaim').setValue(110090001);
        }

        else {
            setTimeout("RetrieveSubGridRecords();", 2500);
        }

    }

    Tuesday, December 8, 2015 3:15 AM

All replies

  • Hi,

    To begin with, the document.getElementById isn't supported so I wouldn't use it for that reason, if it would work today it might not work after next update. That being said, do you get any values at all using the method? I would Query the CRM using a REST call (yes I know the REST interface is deprecated but this is a CRM 2013) where you retrieve that column from all related records.

    Another question, what are you trying to do? You set one attribute Hasclaimed to yes or no a couple of times and the last one is setting the value on the one record? I'm not seeing what you want to do, which doesn't mean that it's incorrect btw.

    Regards


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Tuesday, December 8, 2015 7:01 AM