Answered by:
Custom workflow activity error

Question
-
Hi, In fact I'm just test developing a custom workflow activity because I have an implementation scenario there, this implementation for a call center and they wanna when an operator save a case this particular case should be sent to another database by calling a web service, what's why i'm thinking to develop custom activity and now i'm just developing custom activity, my code as the following: using System; using System.Collections; using System.Workflow.ComponentModel.Compiler; using System.Workflow.ComponentModel.Serialization; using System.Workflow.ComponentModel; using System.Workflow.ComponentModel.Design; using System.Workflow.Runtime; using System.Workflow.Activities; using System.Workflow.Activities.Rules; using System.Reflection; using Microsoft.Crm.Workflow; using Microsoft.Crm.Sdk; using Microsoft.Crm.SdkTypeProxy; using Microsoft.Crm.Sdk.Query; using System.Net; namespace SampleWorkflows { [CrmWorkflowActivity("A sample custom activity")] public partial class QACustomActivity : Activity { protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { try { IContextService contextService = executionContext.GetService<IContextService>(); IWorkflowContext workflowContext = contextService.Context; ICrmService crmService = workflowContext.CreateCrmService(); task entity = new task(); entity.subject = taskId.Value.ToString(); entity.activityid = new Key(taskId.Value); crmService.Create(entity); return ActivityExecutionStatus.Closed; } catch (Exception ex) { throw ex; } } public static DependencyProperty taskIdProperty = DependencyProperty.Register("taskId", typeof(Lookup), typeof(QACustomActivity)); [CrmInput("The id")] [CrmOutput("The output")] [CrmReferenceTarget("task")] public Lookup taskId { get { return (Lookup)base.GetValue(taskIdProperty); } set { base.SetValue(taskIdProperty, value); } } } } And when I did debugging, I found that when I arrive to specific line of code which is "crmService.Create(entity);" I'm recieving an error which is "{System.Web.Services.Protocols.SoapException: Server was unable to process request." and in CRM database, workflow log I found this error message as well "Generic SQL error. type: Platform" I would be thankful if you assist me more. Regards, Maged Said
Monday, June 22, 2009 10:33 AM
Answers
-
Try removing the line entity.activityid = new Key(taskId.value);
Without testing the code, it looks like you are trying to set the id of the task to an id already used by a task and you can't have the same id for two tasks.
- Marked as answer by POP man Tuesday, June 23, 2009 7:44 AM
Monday, June 22, 2009 3:57 PM
All replies
-
Try removing the line entity.activityid = new Key(taskId.value);
Without testing the code, it looks like you are trying to set the id of the task to an id already used by a task and you can't have the same id for two tasks.
- Marked as answer by POP man Tuesday, June 23, 2009 7:44 AM
Monday, June 22, 2009 3:57 PM -
Hi Richard,
Thank you so much. You are right that was the reason behind.
its working fine now.
Regards,
Maged SaidTuesday, June 23, 2009 7:44 AM