/// <inheritdoc /> protected override void Execute(Context context) { var entityId = new Guid(EntityIdString.Get(context)); context.Service.Create(new Entity(Metadata.Annotation.LogicalName) { ["objectid"] = new EntityReference(EntityLogicalName.Get(context), entityId), ["subject"] = Subject.Get(context), ["notetext"] = Content.Get(context), ["filename"] = FileName.Get(context), ["mimetype"] = FileMimeType.Get(context), ["documentbody"] = FileBase64Content.Get(context) }); }
/// <inheritdoc /> protected override void Execute(Context context) { var entityId = new Guid(EntityIdString.Get(context)); var entity = new Entity(Metadata.Annotation.LogicalName) { ["objectid"] = new EntityReference(EntityLogicalName.Get(context), entityId), ["subject"] = Subject.Get(context), ["notetext"] = Content.Get(context) }; var fileName = FileName.Get(context); if (!string.IsNullOrWhiteSpace(fileName)) { entity["filename"] = fileName; entity["mimetype"] = FileMimeType.Get(context); entity["documentbody"] = FileBase64Content.Get(context); } var service = ExecureAsSystem.Get(context) ? context.SystemService : context.Service; service.Create(entity); }
protected override void Execute(CodeActivityContext context) { if (context == null) { throw new InvalidPluginExecutionException("Context not found!"); } ; var workflowContext = context.GetExtension <IWorkflowContext>(); var serviceFactory = context.GetExtension <IOrganizationServiceFactory>(); var orgService = serviceFactory.CreateOrganizationService(workflowContext.UserId); DynamicsDAO dynamicsDAO = new DynamicsDAO(orgService); OptionMetadataCollection optionMetadata = dynamicsDAO.GetOptionsSet(EntityLogicalName.Get <string>(context), "statuscode"); if (optionMetadata != null) { OptionSetMetadata.Set(context, optionMetadata.ConvertToModel()); } else { OptionSetMetadata.Set(context, string.Empty); } }
protected override void Execute(CodeActivityContext context) { if (context == null) { throw new InvalidPluginExecutionException("Context not found!"); } ; var workflowContext = context.GetExtension <IWorkflowContext>(); var serviceFactory = context.GetExtension <IOrganizationServiceFactory>(); var orgService = serviceFactory.CreateOrganizationService(workflowContext.UserId); Guid recordId = Guid.Empty; if (Guid.TryParse(EntityId.Get <string>(context), out recordId)) { DynamicsDAO dynamicsDAO = new DynamicsDAO(orgService); List <AuditDetailModel> audits = dynamicsDAO.RetrieveAuditHistory(EntityLogicalName.Get <string>(context), AttributeLogicalName.Get <string>(context), recordId); if (audits.Count > 0) { if (audits.Where(w => w.Type == "optionsetvalue").ToList().Count > 0) //This is necessary because the audit log, capture all changes in attributes including 'clear' { OptionMetadataCollection optionMetadatas = dynamicsDAO.GetOptionsSetTextOnValue(EntityLogicalName.Get <string>(context), AttributeLogicalName.Get <string>(context)); audits.ReplaceOptionSetValuesByLabels(optionMetadatas); } else if (audits.Where(w => w.Type == "boolean").ToList().Count > 0) { BooleanOptionSetMetadata booleanOptionSetMetadata = dynamicsDAO.GetBooleanTextOnValue(EntityLogicalName.Get <string>(context), AttributeLogicalName.Get <string>(context)); audits.ReplaceBooleanValuesByLabels(booleanOptionSetMetadata); } } ChangesCount.Set(context, audits.Count); History.Set(context, audits.ToJSON()); } }
protected override void Execute(CodeActivityContext executionContext) { _context = executionContext.GetExtension <IWorkflowContext>(); _serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>(); _service = _serviceFactory.CreateOrganizationService(_context.UserId); _tracing = executionContext.GetExtension <ITracingService>(); Logic logic = new Logic(_service); try { AuditChanges auditChanges = new AuditChanges() { AuditHistories = logic.RetrieveRecordChangeHistory(new EntityReference(EntityLogicalName.Get(executionContext).Trim(), Guid.Parse(TargetId.Get(executionContext).Trim()))) }; var Output = Serializer.SerializeToJson(auditChanges); JsonResponse.Set(executionContext, Output); } catch (Exception ex) { throw new InvalidPluginExecutionException(ex.Message + Environment.NewLine + ex.StackTrace, ex); } }
public string GetNameRC() => EntityLogicalName.GetNameRC <CustomEntity>();