private void ProcessDummySavingField(pavelkh_advancedmultiselectitemsetconfiguration itemSetConfig) { var pluginContext = this.PluginContext; var target = pluginContext.InputTarget; var createNew = itemSetConfig.pavelkh_CreateNewDummySavingAttribute ?? false; if (!createNew) { var parentCtx = pluginContext.ExecContext.ParentContext; var checkIfCreateRequired = parentCtx != null && parentCtx.MessageName == MessageName.pavelkh_ItemSetConfigurationImport.ToString(); if (checkIfCreateRequired) { var attributeMetadata = (StringAttributeMetadata)MetadataUtils.GetAttributeMetadata( pluginContext.Service, itemSetConfig.pavelkh_EntityName, itemSetConfig.pavelkh_DummySavingField, new[] { "LogicalName" }); if (attributeMetadata == null) { createNew = true; itemSetConfig.pavelkh_NewDummySavingField = itemSetConfig.pavelkh_DummySavingField; } } } if (createNew) { var attrSchemaName = itemSetConfig.pavelkh_NewDummySavingField; var incorrectNewAttributeParams = string.IsNullOrWhiteSpace(attrSchemaName) || string.IsNullOrWhiteSpace(itemSetConfig.pavelkh_NewDummySavingFieldDisplayName) || itemSetConfig.pavelkh_NewDummySavingAttributeLength == null; if (incorrectNewAttributeParams) { throw new InvalidPluginExecutionException("You would like to create a new Dummy Saving Attribute, but didn't specify all required info for the new attribute correctly."); } var prefixes = ItemSetConfigurationActionManager.GetPrefixList(pluginContext.OrgCtxAsSystemUser); var prefixIsValid = prefixes.Any(r => attrSchemaName.StartsWith(r)); if (!prefixIsValid) { throw new InvalidPluginExecutionException( $"You would like to create a new Dummy Saving Attribute. 'New Attribute Schema Name' should start with one of the following prefix: {string.Join(", ", prefixes)}."); } this.CreateNewDummySavingAttribute(itemSetConfig); target.pavelkh_DummySavingField = itemSetConfig.pavelkh_NewDummySavingField.ToLowerInvariant(); } else { this.ValidateDummySavingFieldAttributeName(itemSetConfig); } target.pavelkh_CreateNewDummySavingAttribute = false; target.pavelkh_NewDummySavingField = null; target.pavelkh_NewDummySavingFieldDisplayName = null; target.pavelkh_NewDummySavingAttributeLength = null; }
private void ValidateAction(pavelkh_advancedmultiselectitemsetconfiguration itemSetConfig) { var actionName = itemSetConfig.pavelkh_SaveChangesHandler; if (string.IsNullOrEmpty(actionName)) { return; } var validActions = ItemSetConfigurationActionManager.GetActionList(this.PluginContext.OrgCtx); if (validActions.All(r => r.UniqueName != actionName)) { throw new InvalidPluginExecutionException($"The '{actionName}' action is not a valid Save Action. Please see documentation regarding when and how to use Save Action."); } }