if
(CurrentOrganizationServiceProxy !=
null
)
{
ActiveService CurrentService =
new
ActiveService(CurrentOrganizationServiceProxy)
List<Task> ListTask = (from c
in
CurrentService.TaskSet
where c.StateCode.Equals(TaskState.Completed)
&& c.ActivityId.Equals(
new
Guid(
"0602713D-FE39-E211-AE0A-005056B60039"
))
select c
).ToList<Task>();
Guid cloneId = Guid.Empty;
Entity clone = EntityExtensions.Clone(ListTask.FirstOrDefault(),
false
);
clone.Id = Guid.NewGuid();
SetStateRequest CurrentEntityStatus =
new
SetStateRequest();
CurrentEntityStatus.State =
new
OptionSetValue(((OptionSetValue)clone.Attributes[
"statecode"
]).Value);
CurrentEntityStatus.Status =
new
OptionSetValue(((OptionSetValue)clone.Attributes[
"statuscode"
]).Value);
clone.Attributes.Remove(
"statuscode"
);
clone.EntityState =
null
;
cloneId = CurrentOrganizationServiceProxy.Create(clone);
CurrentEntityStatus.EntityMoniker =
new
EntityReference(clone.LogicalName, clo/code>);
clone.EntityState =
null
;
cloneId = CurrentOrganizationServiceProxy.Create(clone);