Skip to content

Commit

Permalink
1.0.59.0
Browse files Browse the repository at this point in the history
- Rollup Function: Update to support Whole Number and Float (thanks to TarogStar)
- New action: GetSharepointLocationURL: Added new step to get the sharepoint location absolute URL (thanks to annepessoa)
- New Action: CreateTeam: added new step to creat a Team (owner or access)
- New Action: GetOptionSetValue: addedd new step to get the value (number) of the selectet option of the optionset of a record
  • Loading branch information
Demian Adolfo Raschkovan committed Jul 12, 2020
1 parent 5d0f6f2 commit c0f41ae
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 7 deletions.
Binary file modified msdyncrmWorkflowTools/.vs/msdyncrmWorkflowTools/v15/.suo
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public class AssociateEntity : CodeActivity
[Input("Record URL")]
[ReferenceTarget("")]
public InArgument<String> RecordURL { get; set; }



#endregion

protected override void Execute(CodeActivityContext executionContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@ protected override void Execute(CodeActivityContext executionContext)

#region "Read Parameters"
String _FieldName = this.FieldName.Get(executionContext);
objCommon.tracingService.Trace("_FieldName=" + _FieldName);
String _ParentRecordURL = this.ParentRecordURL.Get(executionContext);

if (_ParentRecordURL == null || _ParentRecordURL == "")
{
return;
}
objCommon.tracingService.Trace("_ParentRecordURL=" + _ParentRecordURL);
string[] urlParts = _ParentRecordURL.Split("?".ToArray());
string[] urlParams=urlParts[1].Split("&".ToCharArray());

string ParentObjectTypeCode=urlParams[0].Replace("etc=","");
string ParentId = urlParams[1].Replace("id=", "");
objCommon.tracingService.Trace("ParentObjectTypeCode=" + ParentObjectTypeCode + "--ParentId=" + ParentId);
Expand Down
93 changes: 93 additions & 0 deletions msdyncrmWorkflowTools/msdyncrmWorkflowTools/Class/CreateTeam.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
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 CreateTeam : CodeActivity
{
[RequiredArgument]
[Input("Team Name")]
[Default("")]
public InArgument<String> TeamName{ get; set; }


[RequiredArgument]
[Input("Team Type")]
public InArgument<int> TeamType{ get; set; }

[RequiredArgument]
[Input("Administrator")]
[ReferenceTarget("systemuser")]
public InArgument<EntityReference> Administrator { get; set; }

[RequiredArgument]
[Input("Business Unit")]
[ReferenceTarget("businessunit")]
public InArgument<EntityReference> BusinessUnit { get; set; }


[Output("Team")]
[ReferenceTarget("team")]
public OutArgument<EntityReference> createdTeam { get; set; }

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"
String _teamName = this.TeamName.Get(executionContext);
int _teamType = this.TeamType.Get(executionContext);
EntityReference _administrator= this.Administrator.Get(executionContext);
EntityReference _businessUnit= this.BusinessUnit.Get(executionContext);

objCommon.tracingService.Trace("_teamName=" + _teamName );
#endregion


#region "Associate Execution"

try
{
msdyncrmWorkflowTools_Class commonClass = new msdyncrmWorkflowTools_Class(objCommon.service);
Guid createdTeamId= commonClass.CreateTeam(_teamName,_teamType, _administrator, _businessUnit);
this.createdTeam.Set(executionContext, new EntityReference("team", createdTeamId));

}
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
@@ -0,0 +1,84 @@
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Workflow;
using System;
using System.Activities;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;


namespace msdyncrmWorkflowTools
{
public class GetOptionSetValue : CodeActivity
{
[RequiredArgument]
[Input("Source Record URL")]
public InArgument<string> SourceRecordUrl { get; set; }

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

[Output("Value")]
public OutArgument<int> SelectedValue { get; set; }

protected override void Execute(CodeActivityContext executionContext)
{
Common objCommon = new Common(executionContext);
objCommon.tracingService.Trace("Load CRM Service from context --- OK");

EntityReference sourceEntityReference = GetSourceEntityReference(objCommon.tracingService, executionContext, objCommon.service);
string attributeName = GetAttributeName(objCommon.tracingService, executionContext);

int value= GetValue(sourceEntityReference, attributeName, objCommon.tracingService, objCommon.service);

this.SelectedValue.Set(executionContext, value);
}

private EntityReference GetSourceEntityReference(ITracingService tracingService, CodeActivityContext executionContext, IOrganizationService organizationService)
{
string sourceRecordUrl = SourceRecordUrl.Get<string>(executionContext) ?? throw new ArgumentNullException("Source URL is empty");
tracingService.Trace("Source Record URL:'{0}'", sourceRecordUrl);
return new DynamicUrlParser(sourceRecordUrl).ToEntityReference(organizationService);
}


private string GetAttributeName(ITracingService tracingService, CodeActivityContext executionContext)
{
string attributeName = AttributeName.Get<string>(executionContext) ?? throw new ArgumentNullException("Attribute Name is empty");
tracingService.Trace("Attribute name:'{0}'", attributeName);
return attributeName;
}



private int GetValue(EntityReference sourceEntityReference, string attributeName, ITracingService tracingService, IOrganizationService organizationService)
{
if (sourceEntityReference == null || attributeName == null)
{
tracingService.Trace("Null parameters have been passed, so string will be empty");
return 0;
}

Entity sourceEntity = organizationService.Retrieve(sourceEntityReference.LogicalName, sourceEntityReference.Id, new ColumnSet(attributeName));
tracingService.Trace("Source record has been retrieved correctly. Id:{0}", sourceEntity.Id);

if (!sourceEntity.Contains(attributeName))
{
tracingService.Trace("Attribues {0} was not found", attributeName);
return 0;
}
int value = 0;
if (sourceEntity.Attributes.Contains(attributeName))
{
value = ((OptionSetValue)sourceEntity.Attributes[attributeName]).Value;
}

return value;
}
}
}
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.58.0")]
[assembly: AssemblyFileVersion("1.0.58.0")]
[assembly: AssemblyVersion("1.0.59.0")]
[assembly: AssemblyFileVersion("1.0.59.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@
<Compile Include="Class\CloneChildren.cs" />
<Compile Include="Class\ConcatenateFromQuery.cs" />
<Compile Include="Class\CountChildEntityRecords.cs" />
<Compile Include="Class\CreateTeam.cs" />
<Compile Include="Class\DeleteOptionValue.cs" />
<Compile Include="Class\CurrencyConvert.cs" />
<Compile Include="Class\DeleteRecordAuditHistory.cs" />
<Compile Include="Class\DynamicUrlParser.cs" />
<Compile Include="Class\GetOptionSetValue.cs" />
<Compile Include="Class\GetMultiSelectOptionSet.cs" />
<Compile Include="Class\GetSharepointLocationURL.cs" />
<Compile Include="Class\IsMemberOfTeam.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,19 @@ public bool InsertOptionValue(bool globalOptionSet, string attributeName, string
return true;

}

public Guid CreateTeam(string teamName, int teamType, EntityReference administrator, EntityReference businessUnit)
{
Entity team = new Entity("team");
team.Attributes.Add("administratorid", administrator);
team.Attributes.Add("name", teamName);
team.Attributes.Add("teamtype", new OptionSetValue(teamType));
team.Attributes.Add("businessunitid", businessUnit);

Guid _teamId = service.Create(team);

return _teamId;
}
public void AssociateEntity(string PrimaryEntityName, Guid PrimaryEntityId, string _relationshipName, string _relationshipEntityName, string entityName, string ParentId)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void Main(string[] args)
//bool regexSuccess = false;
//classObj.StringFunctions(false, "Lead subject", "", false, 0, false, "", "", 50, 0, false, "", ref capitalizedText, ref paddedText, ref replacedText, ref subStringText, ref regexText, ref uppercaseText, ref lowercaseText, ref regexSuccess);


Guid createdTeam=classObj.CreateTeam("PruebaTeam2", 1, new EntityReference("systemuser", new Guid("8fe5fd89-f447-4a38-90f1-1180617fcbc5")), new EntityReference("businessunit", new Guid("6025BC19-2E34-EA11-A812-000D3ABAAFE7")));
//string json = @"{""values"": [{""Author"": ""Lisa Simpson"",""Response Date"": ""2018-02-21T08:13:34.284Z""} ], ""SurveyId"": ""5114FA48-1DE6-E711-80E3-005056B37A5C""}";
//string jsonpath = "values[0].Author";
//string res = classObj.JsonParser(json, jsonpath);
Expand All @@ -64,7 +64,7 @@ static void Main(string[] args)
// classObj.SendEmailToUsersInRole(securityRoleLookup, new EntityReference("email",new Guid("B96825B7-CCB0-E711-810F-5065F38BF4A1")));

//classObj.InsertOptionValue(true, "purchaseprocess", "opportunity", "Tipo22", 22, 3082);
classObj.InsertOptionValue(false, "cre36_test", "account", "3", 3, 3082);
//classObj.InsertOptionValue(false, "cre36_test", "account", "3", 3, 3082);
//classObj.DeleteOptionValue(true,"purchaseprocess", "opportunity", 22);
//classObj.DeleteOptionValue(false, "cdi_test", "opportunity", 1);
// classObj.AssociateEntity("new_test", new Guid("612F10EE-32DB-E711-8116-5065F38BF4A1"), "new_new_test_new_test", "new_test", "new_test", "F1F924DC-32DB-E711-8116-5065F38BF4A1");
Expand All @@ -80,9 +80,9 @@ static void Main(string[] args)
public static IOrganizationService GetCrmService()
{

const string crmServerUrl = "https://xxxx.crm4.dynamics.com";
const string userName = "xxxx@xxxx.com";
const string password = "";
const string crmServerUrl = "https://XXX.crm4.dynamics.com";
const string userName = "XXX@XXX.com";
const string password = "XXX";
//SecureString theSecureString = new NetworkCredential("", password).SecurePassword;


Expand Down

0 comments on commit c0f41ae

Please sign in to comment.