Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

How to call another function variable data to another function mscrm javascript

$
0
0

Hi,

I am trying to get another function data to another function for webapi in mscrm but i am not able to get ldata look my example i am calling function like this sectionduplicate=getsectiondetailbyid(aah_sectionid); but that function not able to throw that variable data code as below

var sectionduplicate;
function getassementdata()
{
	
	 var lookupvalue1= parent.Xrm.Page.getAttribute("aah_assessmentid");
    if (lookupvalue1 != null) {
        var lookup = lookupvalue1.getValue();
        if ((lookup != null)) {
            if (lookup[0].id != null) {
                var lookup1 = new Array();//create a new Array
                lookup1[0] = new Object();
                lookup1[0].id = lookup[0].id;//retrieve the id of the record
                lookup1[0].name = lookup[0].name;//retrieve the name of the record
                lookup1[0].entityType = lookup[0].entityType;//retrieve the entitytype
          //here set lookup field one value into second look up Field
		  parent.Xrm.WebApi.online.retrieveMultipleRecords("aah_aah_assessment_aah_section", "?$select=aah_assessmentid,aah_sectionid&$filter=aah_assessmentid eq"+" "+lookup[0].id).then(
			function success(results) {
				for (var i = 0; i < results.entities.length; i++) {
					var aah_assessmentid = results.entities[i]["aah_assessmentid"];
					var aah_sectionid = results.entities[i]["aah_sectionid"];
					
				   sectionduplicate=getsectiondetailbyid(aah_sectionid);
					
					
					
				}
				
			},
			function(error) {
				parent.Xrm.Utility.alertDialog(error.message);
			}
		);
               // Xrm.Page.getAttribute("new_lookupfield2").setValue(lookup1);
            }
           
        }
    }
}

function getsectiondetailbyid(sectionid1)
{
	var sectiondata1="";
	
	parent.Xrm.WebApi.online.retrieveMultipleRecords("aah_section", "?$select=aah_name,aah_sectionid&$filter=aah_sectionid eq"+" "+sectionid1).then(
    function success(results) {
        for (var i = 0; i < results.entities.length; i++) {
            var aah_name = results.entities[i]["aah_name"];
            var aah_sectionid = results.entities[i]["aah_sectionid"];
		    
			

		
			
			 sectiondata1 +=  '   <div class="card" id="' +aah_sectionid +'">  '  + 
		 '       <div class="card-header" role="tab" id="'+aah_name+'">  '  + 
		 '         <h5 class="mb-0">  '  + 
		 '           <a data-toggle="collapse" href="#'+aah_sectionid+'" aria-expanded="true" aria-controls="'+aah_sectionid+'">  '  + 
		 aah_name + 
		 '           </a>  '  +  
		 '         </h5>  '  + 
		 '   </div>  '  + 
		 '   <div id="'+aah_sectionid+'" class="collapse show" role="tabpanel" aria-labelledby="'+aah_sectionid+'" data-parent="#accordion">  '  + 
		 '         <div class="card-body">  '  + 

		 '         </div>  '  + 
		 '   </div>  '  + 
		 '  </div>  ' ; 
 
       
	
			
			 
        }
		
		return sectiondata1;
		
	
		
		
		
		
    },
    function(error) {
        parent.Xrm.Utility.alertDialog(error.message);
    }
);
	
}



Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>