Skip to content

Commit

Permalink
1.0.39.0:
Browse files Browse the repository at this point in the history
   - New feature: Delete Option Value
  • Loading branch information
Demian Adolfo Raschkovan committed Apr 9, 2017
1 parent 45672c1 commit 173bf2a
Show file tree
Hide file tree
Showing 23 changed files with 145 additions and 9 deletions.
Binary file modified msdyncrmWorkflowTools/.vs/msdyncrmWorkflowTools/v15/.suo
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Metadata.Query;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Metadata;
using msdyncrmWorkflowTools;
using System.ServiceModel;

namespace msdyncrmWorkflowTools
{


public class DeleteOptionValue : CodeActivity
{

#region "Parameter Definition"

[RequiredArgument]
[Input("Global Option Set")]
[Default("false")]
public InArgument<bool> GlobalOptionSet { get; set; }

[RequiredArgument]
[Input("Attribute Name")]
[Default("")]
public InArgument<String> AttributeName { get; set; }

[Input("Entity Name")]
[Default("")]
public InArgument<String> EntityName { get; set; }


[RequiredArgument]
[Input("Option Value")]
[ReferenceTarget("")]
public InArgument<int> OptionValue { get; set; }


#endregion

protected override void Execute(CodeActivityContext executionContext)
{

#region "Load CRM Service from context"

Common objCommon = new Common(executionContext);
objCommon.tracingService.Trace("Load CRM Service from context --- OK");
#endregion

#region "Read Parameters"
bool _GlobalOptionSet = this.GlobalOptionSet.Get(executionContext);
String _AttributeName = this.AttributeName.Get(executionContext);
String _EntityName = this.EntityName.Get(executionContext);

int _OptionValue = this.OptionValue.Get(executionContext);

objCommon.tracingService.Trace("_AttributeName=" + _AttributeName + "--_EntityName=" + _EntityName );
#endregion


#region "Insert Option Value"

try
{
msdyncrmWorkflowTools_Class commonClass = new msdyncrmWorkflowTools_Class(objCommon.service);
commonClass.DeleteOptionValue(_GlobalOptionSet,_AttributeName, _EntityName, _OptionValue);


}
catch (FaultException<OrganizationServiceFault> ex)
{
objCommon.tracingService.Trace("Error : {0} - {1}", ex.Message, ex.StackTrace);
//throw ex;
// if (ex.Detail.ErrorCode != 2147220937)//ignore if the error is a duplicate insert
//{
// throw ex;
//}
}
catch (System.Exception ex)
{
objCommon.tracingService.Trace("Error : {0} - {1}", ex.Message, ex.StackTrace);
//throw ex;
}
#endregion

}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
// Puede especificar todos los valores o usar los valores predeterminados (número de compilación y de revisión)
// usando el símbolo '*' como se muestra a continuación:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.38.1")]
[assembly: AssemblyFileVersion("1.0.38.1")]
[assembly: AssemblyVersion("1.0.39.0")]
[assembly: AssemblyFileVersion("1.0.39.0")]
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<Compile Include="..\msdyncrmWorkflowTools_Class\msdyncrmWorkflowTools_Class.cs">
<Link>msdyncrmWorkflowTools_Class.cs</Link>
</Compile>
<Compile Include="Class\DeleteOptionValue.cs" />
<Compile Include="Class\InsertOptionValue.cs" />
<Compile Include="Class\DisassociateEntity.cs" />
<Compile Include="Class\UpdateChildRecords.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f4c0872ac7c863e2b5bc7543c774ea76e83eca2f
a2266cdc8b173c07c81a9c6774cda9edad8bf22b
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,35 @@ public void QueryValues()
{
}



public void DeleteOptionValue(bool globalOptionSet, string attributeName, string entityName, int optionValue)
{
if (globalOptionSet)
{

DeleteOptionValueRequest deleteOptionValueRequest =
new DeleteOptionValueRequest
{
OptionSetName = attributeName,
Value = optionValue
};
service.Execute(deleteOptionValueRequest);
}
else
{
// Create a request.
DeleteOptionValueRequest insertOptionValueRequest =
new DeleteOptionValueRequest
{
AttributeLogicalName = attributeName,
EntityLogicalName = entityName,
Value = optionValue
};
service.Execute(insertOptionValueRequest);
}

}


public void InsertOptionValue(bool globalOptionSet, string attributeName, string entityName, string optionText, int optionValue, int languageCode)
{
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
20 changes: 15 additions & 5 deletions msdyncrmWorkflowTools/msdyncrmWorkflowTools_ConsoleTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,30 @@ static void Main(string[] args)
{
var classObj = new msdyncrmWorkflowTools_Class(service);

classObj.AssociateEntity("list", new Guid("F9F76AF5-91DF-E311-B8E5-6C3BE5A8B200"), "cdi_emailsend_list", "cdi_emailsend_list", "cdi_emailsend", "5D84160C-A31C-E711-80FF-5065F38A9A01");

classObj.InsertOptionValue(true, "purchaseprocess", "opportunity", "Tipo22", 22, 3082);
classObj.InsertOptionValue(false, "cdi_test", "opportunity", "Tipo4", 1, 3082);


classObj.DeleteOptionValue(true,"purchaseprocess", "opportunity", 22);

classObj.DeleteOptionValue(false, "cdi_test", "opportunity", 1);


//classObj.AssociateEntity("list", new Guid("F9F76AF5-91DF-E311-B8E5-6C3BE5A8B200"), "cdi_emailsend_list", "cdi_emailsend_list", "cdi_emailsend", "5D84160C-A31C-E711-80FF-5065F38A9A01");

//classObj.UpdateChildRecords("contact_customer_accounts", "account", "D17BAB26-98BF-E611-810A-3863BB350E28","emailaddress1", "", "emailaddress1");
//classObj.UpdateChildRecords("contact_customer_accounts", "account", "D17BAB26-98BF-E611-810A-3863BB350E28", "new_campaa", "", "new_campaa");
//classObj.AssociateEntity("opportunity",new Guid("D9AA2BB3-A8F0-E611-80FA-5065F38A4A21"), "opportunitycompetitors_association", "opportunitycompetitors", "competitor", "C53B2A00-57F0-E611-80FA-5065F38A4A21");
//classObj.InsertOptionValue(true,"purchaseprocess", "opportunity", "Tipo22",22, 3082);
// classObj.InsertOptionValue(false,"new_test", "opportunity", "Tipo4",1, 3082);
// classObj.InsertOptionValue(false,"cdi_test", "opportunity", "Tipo4",1, 3082);
}
public static IOrganizationService GetCrmService()
{

const string crmServerUrl = "https://cursorapidoportales1.crm4.dynamics.com";
const string userName = "admin@cursorapidoportales1.onmicrosoft.com";
const string password = "Infoavan1";
const string crmServerUrl = "https://XXXX.crm4.dynamics.com";
const string userName = "admin@XXXX.onmicrosoft.com";
const string password = "XXXXX";

var connectionStringCrmOnline = string.Format("Url={0}; Username={1}; Password={2};authtype=Office365;", crmServerUrl, userName, password);

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 173bf2a

Please sign in to comment.