/// <summary> /// FIELD MUST BE IN PREIMAGE! Returns the effective value of the field in the context record (gets from the target /// entity or if not in gets from the preimage) /// </summary> public object GetField(string fieldName) { if (TargetEntity != null && TargetEntity.Contains(fieldName)) { return(TargetEntity[fieldName]); } else if (MessageName == PluginMessage.Create) { return(null); } else if (MessageName == PluginMessage.Update) { return(PreImageEntity.GetField(fieldName)); } else if (MessageName == PluginMessage.Delete) { return(null); } else { //not sure how to get status if a setstate message throw new InvalidPluginExecutionException("GetFieldMethod Not Implemented for plugin message " + MessageName); } }
/// <summary> /// FIELD MUST BE IN PREIMAGE! Returns the effective value of the field in the context record (gets from the target /// entity or if not in gets from the preimage) /// </summary> public IEnumerable <Entity> GetActivityParties(string fieldName) { if (TargetEntity.Contains(fieldName)) { return(TargetEntity.GetActivityParties(fieldName)); } else if (!IsMessage(PluginMessage.Create)) { var lookThisUp = XrmService.Retrieve(TargetType, TargetId, new[] { fieldName }); PreImageEntity.SetField(fieldName, lookThisUp.GetField(fieldName)); return(PreImageEntity.GetActivityParties(fieldName)); } return(new Entity[0]); }
/// <summary> /// MAYBE TRUE FOR DELETE! FIELD MUST BE IN PREIMAGE FOR UPDATE STEP! Returns if the fields value is logically changing /// by inspecting the Target and Preimage /// </summary> public bool FieldChanging(string fieldName) { if (MessageName == PluginMessage.Create || MessageName == PluginMessage.Update) { return(TargetEntity.Contains(fieldName) && !XrmEntity.FieldsEqual(PreImageEntity.GetField(fieldName), TargetEntity.GetField(fieldName))); } else if (MessageName == PluginMessage.Delete) { return(GetFieldFromPreImage(fieldName) != null); } else { //not sure how to get status if a setstate message throw new InvalidPluginExecutionException("FieldChanging Not Implemented for plugin message " + MessageName); } }
private void ResetThresholdsWhenMonitorTurnedOn() { if (IsMessage(PluginMessage.Create, PluginMessage.Update) && IsStage(PluginStage.PreOperationEvent) && IsMode(PluginMode.Synchronous)) { //set these when turned on so only subsequent failures picked up if (BooleanChangingToTrue(Fields.jmcg_workflowtask_.jmcg_sendnotificationforschedulefailures) && !TargetEntity.Contains(Fields.jmcg_workflowtask_.jmcg_minimumschedulefailuredatetime)) { SetField(Fields.jmcg_workflowtask_.jmcg_minimumschedulefailuredatetime, DateTime.UtcNow); } if (BooleanChangingToTrue(Fields.jmcg_workflowtask_.jmcg_sendnotificationfortargetfailures) && !TargetEntity.Contains(Fields.jmcg_workflowtask_.jmcg_minimumtargetfailuredatetime)) { SetField(Fields.jmcg_workflowtask_.jmcg_minimumtargetfailuredatetime, DateTime.UtcNow); } } }