D365 JavaScript创建一个带有查找、选项集和货币字段的新记录



我正试图通过从JavaScript调用SDK.REST.CreateRecord函数来创建一个新记录。下面是我在没有任何改进的情况下尝试的代码片段-

function CreateProspect(QuoteId) {
SDK.REST.retrieveRecord(QuoteId, "brm_quote", "brm_quotedexipt,brm_inceptiondate,brm_Client", null, function (result) {
var prospect= {
brm_inceptiondate: getFomattedDate(result.brm_inceptiondate),
brm_clientName: {
Id:result.brm_Client.Id, 
LogicalName :"brm_ClientName"
},//lookup fails
brm_currentAmount:{ 
Value:result.brm_quotedexipt.Value
},//moneyfield fails
brm_type: {Value:17200001} //optionset field Fails
}
SDK.REST.createRecord(prospect,"brm_prospect", function(){
alert('New prospect created')
},function (error) { 
alert(error.message); 
})
}, function (error) { 
alert(error.message); 
});
}

需要一些帮助来找到将查找/选项集小数属性添加到javascript对象的正确方法,以便CRM在从SDK Create方法读取时能够正确解释它。

非常感谢在这方面的任何帮助。非常感谢。

要使用LookUp,请使用此

// Set a lookup
account.PrimaryContactId = {
Id: "GUID",               // ID of existing Contact. Must be a Guid
LogicalName: "contact", 
Name: "contact name"      // Provide Existing Contact Name (optional)
};
// Set a money value
account.Revenue = { Value: "2000000.00" };
// Set a picklist value
account.PreferredContactMethodCode = { Value: 2 };

有关更多详细信息:https://arunpotti.wordpress.com/2014/04/14/rest-create-example/

最新更新