Dynamics 365 CRM Connected Field Service 自动发送command
上期降到了怎樣部署connected field service(CFS)
我們假設現在IoT 設備是溫度監控器, 當溫度觸發我們之前預設的溫度值, IoT會通過IoT Hub 發送IoT Alert到CFS中。 第一次觸發, 系統會自動發送reboot的command。
?
為了有更好的用戶體驗, 我們需要自動發送command。
自動發送非常簡單。
首先,我們需要創建一個workflow
?我們的workflow需要在IoT Alert創建的時候觸發。
這個workflow需要有以下兩步:
1. 獲取到當前IoT Alert的GUID
2. 創建IoT device command 并且把IoT Alert的GUID 綁定進去。
?
首先我們需要創建workflow。
如果不清楚workflow的,可以查看我的workflow 掃盲貼?Step by Step 開發dynamics CRM
public class RetrieveCFSData : CodeActivity{[Input("Key")]public InArgument<string> Key { get; set; }[ReferenceTarget("msdyn_iotalert")][Output("IoTAlertId")]public OutArgument<EntityReference> IoTAlertId { get; set; }protected override void Execute(CodeActivityContext executionContext){//Create the tracing serviceITracingService tracingService = executionContext.GetExtension<ITracingService>();//Create the contextIWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity){// Obtain the target entity from the input parameters. Entity iotAlert = (Entity)context.InputParameters["Target"];var alertId = iotAlert.Attributes["msdyn_iotalertid"].ToString(); //Update Record by using Custom Assembly output parametervar iotAlertRef = new EntityReference("msdyn_iotalert", new Guid(alertId));iotAlertRef.Name = "Hello World From Workflow";IoTAlertId.Set(executionContext, iotAlertRef);}}}?
我們把這個workflow添加到之前簡歷好的step當中。不用set properties
?并且,我們要創建一個IoT Device Command 的step。
在這個step當中, 我們需要在operator找到我們創建好的step 1 custom?workflow。
并且把parent alert 做綁定。
?
轉載于:https://www.cnblogs.com/TheMiao/p/11083546.html
總結
以上是生活随笔為你收集整理的Dynamics 365 CRM Connected Field Service 自动发送command的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微信小程序 PDF下载打印
- 下一篇: object.definePropert