Dynamics 365 CRM Connected Field Service 自动发送command
上期降到了怎樣部署connected field service(CFS)
我們假設(shè)現(xiàn)在IoT 設(shè)備是溫度監(jiān)控器, 當(dāng)溫度觸發(fā)我們之前預(yù)設(shè)的溫度值, IoT會(huì)通過IoT Hub 發(fā)送IoT Alert到CFS中。 第一次觸發(fā), 系統(tǒng)會(huì)自動(dòng)發(fā)送reboot的command。
?
為了有更好的用戶體驗(yàn), 我們需要自動(dòng)發(fā)送command。
自動(dòng)發(fā)送非常簡(jiǎn)單。
首先,我們需要?jiǎng)?chuàng)建一個(gè)workflow
?我們的workflow需要在IoT Alert創(chuàng)建的時(shí)候觸發(fā)。
這個(gè)workflow需要有以下兩步:
1. 獲取到當(dāng)前IoT Alert的GUID
2. 創(chuàng)建IoT device command 并且把IoT Alert的GUID 綁定進(jìn)去。
?
首先我們需要?jiǎng)?chuàng)建workflow。
如果不清楚workflow的,可以查看我的workflow 掃盲貼?Step by Step 開發(fā)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);}}}?
我們把這個(gè)workflow添加到之前簡(jiǎn)歷好的step當(dāng)中。不用set properties
?并且,我們要?jiǎng)?chuàng)建一個(gè)IoT Device Command 的step。
在這個(gè)step當(dāng)中, 我們需要在operator找到我們創(chuàng)建好的step 1 custom?workflow。
并且把parent alert 做綁定。
?
轉(zhuǎn)載于:https://www.cnblogs.com/TheMiao/p/11083546.html
總結(jié)
以上是生活随笔為你收集整理的Dynamics 365 CRM Connected Field Service 自动发送command的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微信小程序 PDF下载打印
- 下一篇: object.definePropert