locked
JavaScript:Concat value in Text box from Subgrid's column 1 RRS feed

  • Question

  • Hi,

    In OpportunityProduct Entity we have added Product Team subgrid. Want to concat all the column1's value to text box. 

    Unable to set the values. Please refer the below code and advise what should be the code for the last 3 lines(BOLD lines).

    function RetrieveSubGridRecords() {
        if (document.getElementById("ProductTeam")) {
            var grid = document.getElementById("ProductTeam").control;
            for (var rowNo = 0; rowNo < grid.GetRecordsFromInnerGrid().length; rowNo++)
                //for (var cellNo = 0; cellNo < grid.GetRecordsFromInnerGrid()[rowNo][3].cells.length; cellNo++)
                   alert(grid.GetRecordsFromInnerGrid()[rowNo][3].cells[1].outerText);

                    var  FullName="grid.GetRecordsFromInnerGrid()[rowNo][3].cells[1].outerText";
                   alert(Fullname);
                  
        
                   Xrm.Page.getAttribute("new_productteammembers").setValue(grid.GetRecordsFromInnerGrid()[rowNo][3].cells[1].outerText);
        }
        else {
            setTimeout("RetrieveSubGridRecords();", 2500);
        }

    }

    Thanks.


    Regards.


    • Edited by MSCRM15 Tuesday, September 16, 2014 10:54 AM title
    Tuesday, September 16, 2014 10:54 AM

Answers

  • Hi,

    Please use the code below: 

    function RetrieveSubGridRecords() {
        if (document.getElementById("ProductTeam")) {
            var grid = document.getElementById("ProductTeam").control;
    		var FullName = [];
            for (var rowNo = 0; rowNo < grid.GetRecordsFromInnerGrid().length; rowNo++)
                //for (var cellNo = 0; cellNo < grid.GetRecordsFromInnerGrid()[rowNo][3].cells.length; cellNo++)
                   
    			{  				
                    FullName[rowNo] = grid.GetRecordsFromInnerGrid()[rowNo][3].cells[1].outerText;
                   }
                  var productMembers = FullName.join([separator = ';']);
                                  
        
                   Xrm.Page.getAttribute("new_productteammembers").setValue(productMembers);
        }
        else {
            setTimeout("RetrieveSubGridRecords();", 2500);
        }
    
    }

    Saad

    • Marked as answer by MSCRM15 Thursday, September 18, 2014 4:53 PM
    Wednesday, September 17, 2014 10:23 AM
  • This method is unsupported by Microsoft. You should use oData to retreive multiple ProductTeams and then concatinate new_productteammembers and populate it in the field. Ideally you should do this thing with a plugin so that it works with data import etc.

    Regards Faisal

    • Marked as answer by MSCRM15 Thursday, September 18, 2014 4:56 PM
    Wednesday, September 17, 2014 10:58 AM

All replies

  • Hi,

    Please use the code below: 

    function RetrieveSubGridRecords() {
        if (document.getElementById("ProductTeam")) {
            var grid = document.getElementById("ProductTeam").control;
    		var FullName = [];
            for (var rowNo = 0; rowNo < grid.GetRecordsFromInnerGrid().length; rowNo++)
                //for (var cellNo = 0; cellNo < grid.GetRecordsFromInnerGrid()[rowNo][3].cells.length; cellNo++)
                   
    			{  				
                    FullName[rowNo] = grid.GetRecordsFromInnerGrid()[rowNo][3].cells[1].outerText;
                   }
                  var productMembers = FullName.join([separator = ';']);
                                  
        
                   Xrm.Page.getAttribute("new_productteammembers").setValue(productMembers);
        }
        else {
            setTimeout("RetrieveSubGridRecords();", 2500);
        }
    
    }

    Saad

    • Marked as answer by MSCRM15 Thursday, September 18, 2014 4:53 PM
    Wednesday, September 17, 2014 10:23 AM
  • This method is unsupported by Microsoft. You should use oData to retreive multiple ProductTeams and then concatinate new_productteammembers and populate it in the field. Ideally you should do this thing with a plugin so that it works with data import etc.

    Regards Faisal

    • Marked as answer by MSCRM15 Thursday, September 18, 2014 4:56 PM
    Wednesday, September 17, 2014 10:58 AM
  • Thank you. This helps!

    Regards.

    Thursday, September 18, 2014 4:54 PM
  • Thank you for pointing out this.. never thought in that way.. will implement the same.

    Regards.

    Thursday, September 18, 2014 4:55 PM