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

How to fetch Child Territory and owner of that Territories in crm 2011 through javascript?

$
0
0

Hello,

I have fetched the log in User and its Territory.

And then i filter User entity with that fetched Territory and

got the list of user under that Territory

and set to the new lookup as shown in my below code.

var tId;var fillterXml;functionAdvancedFilteredLookup(){GetCurrentUserTerritory(); setInterval('SetLookUp();',3000);}functionGetCurrentUserTerritory(){var ODATA_ENDPOINT ="/XRMServices/2011/OrganizationData.svc";var serverUrl ="http://******/CRMSERVER2011"; $.ajax({ type:"GET", contentType:"application/json; charset=utf-8", datatype:"jsonp", url: serverUrl + ODATA_ENDPOINT +"/SystemUserSet?$top="+1, beforeSend:function(XMLHttpRequest){XMLHttpRequest.setRequestHeader("Accept","application/json");}, success:function(data, textStatus,XmlHttpRequest){ tId = data.d.results[0].TerritoryId.Id;if( tId !=null|| tId !=undefined){ fillterXml +="<filter type='and'>"; fillterXml +="<condition attribute='territoryid' operator='eq' value='"+ tId +"'/>"; fillterXml +="</filter>";}}, error:function(XmlHttpRequest, textStatus, errorThrown){ alert('error');}});}functionSetLookUp(){var viewId ="{FD140AAF-4DF4-11DD-BD17-0019B9312238}";// new idvar entityName ="systemuser";var primaryKeyName ="systemuserid";var customViewName ="Filtered User";var user =Xrm.Page.context.getUserId();var userId = user.substring(1,37); jQuery.support.cors =true;var fetchXml ="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"; fetchXml +="<entity name='systemuser'>"; fetchXml += fillterXml; fetchXml +="</entity></fetch>";//alert (fetchXml);var layoutXml ="<grid name='resultset' "+"object='1' "+"jump='firstname' "+"select='1' "+"icon='1' "+"preview='1'>"+"<row name='result' "+"id='systemuserid'>";//for(var i=0; i< viewColumns.length; i++) layoutXml +="<cell name='firstname' width='200' />"; layoutXml +="</row></grid>";try{var lookupControl =Xrm.Page.ui.controls.get("new_clinicalspecialist"); lookupControl.addCustomView(viewId, entityName, customViewName , fetchXml, layoutXml,true);}catch(err){}}

I successfully got the Users under that Territory.

But i want one more condition here before getting the Users list.

Condition : Fetch All Child Territory (related territory to Parent Territory, there is a custom fields 'Parent Territory' on Territory form) of log in user Territory and find the list of all users under those territories.

Can anyone help me in this condition with my pasted code ?

Any help would be Appreciated.


var tId;var fillterXml;functionAdvancedFilteredLookup(){GetCurrentUserTerritory(); setInterval('SetLookUp();',3000);}functionGetCurrentUserTerritory(){var ODATA_ENDPOINT ="/XRMServices/2011/OrganizationData.svc";var serverUrl ="http://******/CRMSERVER2011"; $.ajax({ type:"GET", contentType:"application/json; charset=utf-8", datatype:"jsonp", url: serverUrl + ODATA_ENDPOINT +"/SystemUserSet?$top="+1, beforeSend:function(XMLHttpRequest){XMLHttpRequest.setRequestHeader("Accept","application/json");}, success:function(data, textStatus,XmlHttpRequest){ tId = data.d.results[0].TerritoryId.Id;if( tId !=null|| tId !=undefined){ fillterXml +="<filter type='and'>"; fillterXml +="<condition attribute='territoryid' operator='eq' value='"+ tId +"'/>"; fillterXml +="</filter>";}}, error:function(XmlHttpRequest, textStatus, errorThrown){ alert('error');}});}functionSetLookUp(){var viewId ="{FD140AAF-4DF4-11DD-BD17-0019B9312238}";// new idvar entityName ="systemuser";var primaryKeyName ="systemuserid";var customViewName ="Filtered User";var user =Xrm.Page.context.getUserId();var userId = user.substring(1,37); jQuery.support.cors =true;var fetchXml ="<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"; fetchXml +="<entity name='systemuser'>"; fetchXml += fillterXml; fetchXml +="</entity></fetch>";//alert (fetchXml);var layoutXml ="<grid name='resultset' "+"object='1' "+"jump='firstname' "+"select='1' "+"icon='1' "+"preview='1'>"+"<row name='result' "+"id='systemuserid'>";//for(var i=0; i< viewColumns.length; i++) layoutXml +="<cell name='firstname' width='200' />"; layoutXml +="</row></grid>";try{var lookupControl =Xrm.Page.ui.controls.get("new_clinicalspecialist"); lookupControl.addCustomView(viewId, entityName, customViewName , fetchXml, layoutXml,true);}catch(err){}}

Viewing all articles
Browse latest Browse all 87499

Trending Articles



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