-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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
Showing
9 changed files
with
206 additions
and
7 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
msdyncrmWorkflowTools/msdyncrmWorkflowTools/Class/CreateTeam.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
} | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
msdyncrmWorkflowTools/msdyncrmWorkflowTools/Class/GetOptionSetValue.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters