2016-11-26 54 views
0

我對CRM動態2016非常新穎。在編寫以下JavaScript代碼時需要幫助。我有兩個實體Capacity和Scenario。在Capacity表格中,有一個屬於Scenario實體的查找字段,即爲場景選擇查找值時,屬於場景實體的其餘字段應該自動填充。它們具有映射。使用REST的JavaScript

// JavaScript源代碼

function GetScenarioData() 

{ 

var scenario = Xrm.Page.getAttribute("spa_scenario").getValue(); 

if (scenario != null) 

{ 
    var scenarioID = scenario[0].id; 
    var scenarioName = scenario[0].name;ST 
    SDK.REST.retrieveRecord(scenarioID, "msdyn_project", null, null, function getDetails(data) { 

     var scenarioDescription = data.spa_ScenarioDescription; 
     var organizationPathID = data.spa_OrganationPath.Id; 
     var organizationName = data.spa_OrganationPath.Name; 
     var capacityChampionID = data.spa_CapacityChampion.Id; 
     var capacityChampionName = data.spa_CapacityChampion.Name; 
     var fiscalCycleID = data.spa_FiscalCycle.Id; 
     var fiscalCycleName = data.spa_FiscalCycle.Name; 
     var budgetID = data.spa_Budget.Id; 
     var budgetName = data.spa_Budget.Name; 
     var ionfunding = data.spa_ImpactofNotFunding; 
     }, errorHandler); 
} 

} 

function errorHandler(error) 
{ 
    alert("Error:" + error.message); 
} 

我已經wriiten這個代碼到目前爲止..這犯規幫我找回。請幫忙。

+0

你可以分享什麼數據的價值? – Deep

+0

我雖然它的內置JS功能 –

回答

0
function GetScenarioData() 

{ 

var scenario = Xrm.Page.getAttribute("spa_scenario").getValue(); 

if (scenario != null) 
{ 
    var scenarioID = scenario[0].id; 
    var scenarioName = scenario[0].name; 
    SDK.REST.retrieveRecord(scenarioID, 
     scenario[0].entityType, 
     "spa_ScenarioDescription,spa_OrganationPath,spa_CapacityChampion,spa_FiscalCycle,spa_Budget,spa_ImpactofNotFunding", 
     null, 
     function getDetails(data) { 
      var scenarioDescription = data.spa_ScenarioDescription; 
      var organizationPathID = data.spa_OrganationPath.Id; 
      var organizationName = data.spa_OrganationPath.Name; 
      var capacityChampionID = data.spa_CapacityChampion.Id; 
      var capacityChampionName = data.spa_CapacityChampion.Name; 
      var fiscalCycleID = data.spa_FiscalCycle.Id; 
      var fiscalCycleName = data.spa_FiscalCycle.Name; 
      var budgetID = data.spa_Budget.Id; 
      var budgetName = data.spa_Budget.Name; 
      var ionfunding = data.spa_ImpactofNotFunding; 
     }, 
    errorHandler); 
} 

} 

function errorHandler(error) 
{ 
    alert("Error:" + error.message); 
}