locked
Called Workflow "Waiting" RRS feed

  • Question

  • hello,

    I have used the below code to call one of my workflows in a windows service. The call is scheduled at 24hr intervals.

    // Set up the CRM Service.
    CrmAuthenticationToken token = new CrmAuthenticationToken();
    // You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
    token.AuthenticationType = 0;
    token.OrganizationName = "AdventureWorksCycle";

    CrmService service = new CrmService();
    service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
    service.CrmAuthenticationTokenValue = token;
    service.Credentials = System.Net.CredentialCache.DefaultCredentials;

    // Create an ExecuteWorkflow request.
    ExecuteWorkflowRequest request = new ExecuteWorkflowRequest();

    //Assign the ID of the workflow you want to execute to the request.    
    request.WorkflowId = new Guid("b050f053-6968-dc11-bb3a-0003ffbad37a");

    //Assign the ID of the entity to execute the workflow on to the request.
    request.EntityId = new Guid("1DCDEE97-35BB-44BE-8353-58BC36592656");

    // Execute the workflow.
    ExecuteWorkflowResponse response = (ExecuteWorkflowResponse)service.Execute(request);

    The call is being made successfully and starts fine on CRM, however for some reason the workflow status reason remains "Waiting". I cannot understand why because when I run the workflow manually it work fine. The windows service is deployed on the CRM server and therefore the owner of the workflows appear to be "SYSTEM", could this be the problem?

    Thank you

    Darren

    Friday, August 6, 2010 7:27 AM

Answers

All replies

  • Try to open workflow instance form system job and check if you see some error there


    Mahain : http://mahenderpal.wordpress.com
    Friday, August 6, 2010 8:01 AM
    Moderator
  • These are the values of the workflow system job attributes: 

    'error code': -2147201001 and 'Message':

    System.Workflow.Activities.Rules.RuleExpressionCondition.Evaluate(RuleExecution execution)  at System.Workflow.Activities.Rules.RuleConditionReference.Evaluate(Activity activity, IServiceProvider provider)  at System.Workflow.Activities.IfElseActivity.Execute(ActivityExecutionContext executionContext)  at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)  at System.Workflow.ComponentModel.CompositeActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)  at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext)  at System.Workflow.ComponentModel.ActivityExecutionFilter.Execute(Activity activity, ActivityExecutionContext executionContext)  at System.Workflow.ComponentModel.FaultAndCancellationHandlingFilter.Execute(Activity activity, ActivityExecutionContext executionContext)  at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)  at System.Workflow.Runtime.Scheduler.Run() Inner Exception: Microsoft.Crm.CrmNotSupportedException: Invalid type conversion  at Microsoft.Crm.Workflow.ValueConverters.ValueConverterBase.ConvertTo(Type targetType, Object sourceValue, String entityName, String attributeName)  at Microsoft.Crm.Workflow.Services.CrmWorkflowService.ConvertToCrmTypeWithMetadata(Type targetType, Object sourceValue, String entityName, String attributeName)  at Microsoft.Crm.Workflow.Services.CrmWorkflowService.FormatValue(Object sourceValue, String entityName, String attributeName)  at Microsoft.Crm.Workflow.CrmWorkflow.GetEntityProperty(DynamicEntity entity, String propertyName) Inner Exception: System.Web.Services.Protocols.SoapException: Server was unable to process request. Detail: <detail><error>  <code>0x80040217</code>  <description>usersettings With Id = a8dbe655-4632-4b33-8832-87dab4148b1c Does Not Exist</description>  <type>Platform</type> </error></detail>  at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)  at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)  at Microsoft.Crm.SdkTypeProxy.CrmService.Execute(Request Request)  at Microsoft.Crm.Asynchronous.SdkTypeProxyCrmServiceWrapper.Execute(Object request)  at Microsoft.Crm.Asynchronous.UserSettingsCacheLoader.RetrieveUserSettings(ICrmService crmService, Guid userId)  at Microsoft.Crm.Asynchronous.UserSettingsCacheLoader.LoadCacheData(Guid userId, IOrganizationContext context)  at Microsoft.Crm.Caching.BasicCrmCache`2.CreateEntry(TKey key, IOrganizationContext context)  at Microsoft.Crm.Caching.BasicCrmCache`2.LookupEntry(TKey key, IOrganizationContext context)  at Microsoft.Crm.Workflow.WorkflowUserContext.get_User()  at Microsoft.Crm.Workflow.ValueConverters.ValueConverterBase.FormatDate(CrmDateTime dateValue)  at Microsoft.Crm.Workflow.ValueConverters.CrmDateTimeConverter.InternalConvert(Type targetType, Object value)  at Microsoft.Crm.Workflow.ValueConverters.ValueConverterBase.ConvertTo(Type targetType, Object sourceValue, String entityName, String attributeName)

    Also note: I am using a custom workflow step which works fine when started manually. could this be the cause?

    Thanks

    Darren

    Friday, August 6, 2010 8:53 AM
  • Not sure but seems to be authentication issue,

    "usersettings With Id = a8dbe655-4632-4b33-8832-87dab4148b1c Does Not"

    try to check if user exists with this ID ???


    Mahain : http://mahenderpal.wordpress.com
    Friday, August 6, 2010 9:13 AM
    Moderator
  • It is the 'SYSTEM' user!

    Friday, August 6, 2010 9:27 AM
  • Ok, Have you installed latest rollup in you server ???


    Mahain : http://mahenderpal.wordpress.com
    Friday, August 6, 2010 9:48 AM
    Moderator
  • We are running on CRM update rollup 9.

    Or do you mean windows server rollups?

    Darren

    Friday, August 6, 2010 10:06 AM
  • Actually is CRM rollup 11.

    What rights have the workflow when you start it manually? And what rights have the workflow when the CRM automatically.

    Maybe you start the workflow manually with admin right’s and the system starts the workflow only with user rights.

     


    Viele Grüße Stefan
    Friday, August 6, 2010 10:58 AM
  • Actually is CRM rollup 11.

    What rights have the workflow when you start it manually? And what rights have the workflow when the CRM automatically.

    Maybe you start the workflow manually with admin right’s and the system starts the workflow only with user rights.

     


    Viele Grüße Stefan

    FYI. Rollup 12 released. http://support.microsoft.com/default.aspx?kbid=2028381

    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    • Marked as answer by Jim Glass Jr Friday, August 6, 2010 4:10 PM
    Friday, August 6, 2010 11:09 AM
    Moderator
  • So do you recommend UR 11?

    The 'SYSTEM' user does not have any roles, similary I also found the 'INTEGRATION' user also without roles. What exactly do these default users do? Do you think I can assign roles to them? or maybe I can run the workflow using another specific user account with admin roles? Thanks.

    Darren

    Friday, August 6, 2010 11:17 AM
  • Try to run set run with some other user who have Admin rights

    service.Credentials = new NetworkCredential("ADMIn user", "PASSWORD", "ORG NAMe");

     


    Mahain : http://mahenderpal.wordpress.com
    Friday, August 6, 2010 11:24 AM
    Moderator
  • Sorry i mean 12. This was a typing error.
    Viele Grüße Stefan
    Friday, August 6, 2010 11:45 AM
  • No i recommend UR12. (it was an typing error with UR11)
    Viele Grüße Stefan
    • Marked as answer by Jim Glass Jr Friday, August 6, 2010 4:10 PM
    Friday, August 6, 2010 11:49 AM
  • I did as you said, and used the domain instead and seems to be working now.

    service.Credentials = new System.Net.NetworkCredential("ADMIN user", "PASSWORD", "DOMAIN");

    Thanks All.

    Darren

    Friday, August 6, 2010 1:28 PM
  • yes, you need to use Domain name there
    Mahain : http://mahenderpal.wordpress.com
    • Marked as answer by Jim Glass Jr Friday, August 6, 2010 4:10 PM
    Friday, August 6, 2010 1:39 PM
    Moderator
  • When you create the service at the start of your workflow (under
    ActivityExecutionStatus) you just need to use :

    IContextService contextService =
    (IContextService)executionContext.GetService(typeof(IContextService));
    IWorkflowContext ctx = contextService.Context;
    ICrmService icrmService = ctx.CreateCrmService(true);


    You replace the (true) with nothing to use the calling user, otherwise it
    uses the SYSTEM user.

    If you are working with the IPluginExecution (for plugin not workflow) I
    believe it uses the opposite, where (true) refers to using the "current or
    calling" user.


    Friday, December 31, 2010 10:54 AM