2013-01-02 30 views
1

我創建了一個HTML Web資源,當點擊一個功能區按鈕時顯示。在這個彈出窗口中,我有一個下拉列表,我想用我使用fetchXml查詢獲得的記錄列表填充。在html彈出窗口中執行提取查詢

我的問題是,我已經嘗試了幾種不同的方式來執行查詢,但它總是帶着錯誤返回。我猜測彈出不會有父窗體將具有相同的函數範圍,所以我需要做一些不同的事情來執行查詢。

目前,我已經加載了包含執行提取所需功能的外部腳本,但代碼無法看到_HtmlEncode的CRM函數,因此失敗。

有什麼方法可以讓我看到CRM功能的彈出窗口?還是有另外一種方法呢?

編輯:一些示例代碼

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:asp> 
<head> 
    <title>Re-Assign</title> 
    <script type=text/javascript src="ClientGlobalContext.js.aspx"></script> 

    <script type=text/javascript src="http://crm/DEVCRM/WebResources:ts_/scripts/fetch_global.js"></script> 

    <script type=text/javascript> 

    function OnLoad_GetAreasAndConsultants() { 

     var fetchXml = '<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0"><entity name="ts_solution_area"><attribute name="ts_solution_areaid"/><attribute name="ts_descriptor"/><attribute name="createdon"/> <order descending="false" attribute="ts_descriptor"/><filter type="and"><condition attribute="statecode" value="0" operator="eq"/></filter></entity></fetch>'; 
     var fetchedRecords = FetchRecordsToolKit.Fetch(fetchXml); 

     if (fetchedRecords !== null) { 

      var areaList = document.getElementById("ddl_solution_area") 

      for (var i=0; i<fetchedRecords.length;i++) { 

       var name = fetchedRecords[i].getValue("ts_descriptor"); 

       areaList.options[select.options.length] = new Option(name, i); 
      } 
     } 
    } 
</script> 

感謝

+0

護理粘貼一些示例代碼? –

+0

我已經添加了一些代碼,我試圖調用的腳本是fetch_global腳本 – jimminybob

+0

您目前收到的錯誤是什麼? –

回答

1

我建立的東西專門用於執行HTML網頁資源中獲取。

https://github.com/paul-way/JCL/blob/master/jcl.js

下面是使用它的一個例子:

var processProjectInfo = function (data) { 
    if (data.length > 0) { 
     // Set Project Header Information 
     $('#ProjectTitle').html(data[0].attributes.new_name.value); 
     $('#CompanyName').html(data[0].attributes.new_accountid.name); 
    } 
}; 

var loadProjectInfo = function (guid) { 
    var fetchXML = " " + 
     "<fetch mapping='logical' count='10'>" + 
     " <entity name='new_project'>" + 
     " <all-attributes/>" + 
     " <filter>" + 
     "  <condition attribute='new_projectid' operator='eq' value='" + guid + "' />" + 
     " </filter>" + 
     " </entity>" + 
     "</fetch>"; 

    JCL.Fetch(fetchXML, processProjectInfo); 
};