[英]Calling a custom action from power apps component
我正在嘗試創建一個組件,該組件向我的環境中的自定義操作發出發布請求。 這個動作有一個叫做leadid
的輸入和一個叫做data
的output,當被調用時會觸發一個自定義插件。 但是,我無法弄清楚如何從我的組件中調用此操作。
我知道您可以使用this._context.webAPI.retrieveMultipleRecords(entity, query)
撥打電話,但我並不想實現這一點。
我直接在控制台(在瀏覽器中)嘗試了以下操作,它運行良好,但是在我的 TypeScript 文件中使用相同的代碼時,我得到一個錯誤Xrm is not defined
:
fetch(Xrm.Page.context.getClientUrl() + "/api/data/v9.2/dev_GetData", {
"method":"POST",
"headers":{
"Accept": "application/json",
"Content-Type": "application/json; charset=utf-8",
"OData-MaxVersion": "4.0",
"OData-Version": "4.0"
},
"body": JSON.stringify({
"leadid": "7ba18ae0-4d0e-ea11-a813-000d3a1bbd52"
})
}).then((response) => response.json())
.then((data) => {
console.log(data);
})
我覺得這很奇怪,因為當我在其他部分(頁面、上下文、getClientUrl)上使用 hover 時,它給了我它所做的細節。
我可能做錯了什么,或者如何在不使用 Xrm.page 的情況下獲得客戶端 url ...?
Dataverse 的托管解決方案/附加工具將為您提供帶有 webapi 調用實際值的代碼片段。 工具是Dataverse Rest Builder
https://www.xrmtoolbox.com/plugins/GuidoPreite.DRB/
潛在客戶資格操作的示例代碼片段
var execute_QualifyLead_Request = {
// Parameters
entity: { entityType: "lead", id: "524a9e0b-f3e6-e711-80e9-005056936c69" }, // entity
CreateAccount: true, // Edm.Boolean
CreateContact: true, // Edm.Boolean
CreateOpportunity: true, // Edm.Boolean
Status: 1, // Edm.Int32
getMetadata: function () {
return {
boundParameter: "entity",
parameterTypes: {
entity: { typeName: "mscrm.lead", structuralProperty: 5 },
CreateAccount: { typeName: "Edm.Boolean", structuralProperty: 1 },
CreateContact: { typeName: "Edm.Boolean", structuralProperty: 1 },
CreateOpportunity: { typeName: "Edm.Boolean", structuralProperty: 1 },
Status: { typeName: "Edm.Int32", structuralProperty: 1 }
},
operationType: 0, operationName: "QualifyLead"
};
}
};
Xrm.WebApi.online.execute(execute_QualifyLead_Request).then(
function success(response) {
if (response.ok) { return response.json(); }
}
).then(function (responseBody) {
var result = responseBody;
console.log(result);
// Return Type: Collection(mscrm.crmbaseentity)
}).catch(function (error) {
console.log(error.message);
});
[1]: https://github.com/GuidoPreite/DRB
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.