locked
No from or join clause could be found for table alias workflow1 RRS feed

  • Question

  • Hi , 

    I am trying to get Process Id from Process Stage Set. 

    I can able to get the Output with Bellow link as mentioned.

    http://sahanajain.blogspot.in/2014/01/programatically-change-business-process.html

    To get Process  Id [ First they are retrieving value from workflow with the workflow name and then again Querry to process stage.

    I tried to avoid two service call . so that i have modified the code.

    • But i am getting an Error  No from or join clause could be found for table alias workflow1

    I am providing my Sample Code along with Error Screen Short 

                QueryExpression getProcessId = new QueryExpression
                {
                    EntityName = "processstage",
                    ColumnSet = new ColumnSet("stagename", "processstageid")
                };
                getProcessId.Criteria.AddCondition("primaryentitytypecode", ConditionOperator.Equal, "opportunity");
                getProcessId.Criteria.AddCondition("stagename", ConditionOperator.Equal, "Propose");
    
                getProcessId.NoLock = true;
    
                LinkEntity Workflow = new LinkEntity
                {
                    
                    JoinOperator = JoinOperator.Natural,
                    EntityAlias = "wnkj",
                    LinkFromEntityName = "processstage",
                    LinkToEntityName = "workflow",
                    LinkFromAttributeName = "processid",
                    LinkToAttributeName = "activeworkflowid"
              
                };
                Workflow.LinkCriteria.AddCondition("name", ConditionOperator.Equal, "Opportunity Process");
                getProcessId.LinkEntities.Add(Workflow);
    
                EntityCollection test = _organizationSericeProxy.RetrieveMultiple(getProcessId);

    Plz guide where i am going wrong. 

    Thanks .. 

    Tuesday, June 30, 2015 10:16 PM

All replies

  • I think your LinkEntity should join to the workflowid attribute (the primary key), and not the activeworkflowid

    LinkEntity Workflow = new LinkEntity
                {
                    
                    JoinOperator = JoinOperator.Natural,
                    EntityAlias = "wnkj",
                    LinkFromEntityName = "processstage",
                    LinkToEntityName = "workflow",
                    LinkFromAttributeName = "processid",
                    LinkToAttributeName = "workflowid"
              
                };


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Wednesday, July 1, 2015 8:49 AM
    Moderator
  • Hi David,

    I have tried with your bellow approach but still i am facing the same issue.

    Getting Same Error Message .

    Thanks 

    Wednesday, July 1, 2015 5:45 PM
  • Hi,

    Did you find a solution for your problem?

    Wednesday, December 2, 2015 9:16 AM
  • try following code
                String fetchXml1 = string.Format(@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
                                                  <entity name='workflow'>
                                                    <attribute name='workflowid' />
                                                    <attribute name='name' />
                                                    <order attribute='name' descending='false' />
                                                    <filter type='and'>
                                                      <condition attribute='name' operator='not-null' />
                                                      <condition attribute='primaryentity' operator='eq' value='3' />
                                                    </filter>
                                                    <link-entity name='processstage' from='processid' to='workflowid' alias='ab'>
                                                      <filter type='and'>
                                                        <condition attribute='stagename' operator='eq' value='{0}' />
                                                      </filter>
                                                    </link-entity>
                                                  </entity>
                                                </fetch>", "Propose");
    
                    // Build fetch request and obtain results.
                    RetrieveMultipleRequest efr1 = new RetrieveMultipleRequest()
                    {
                        Query = new FetchExpression(fetchXml1)
                    };
                    EntityCollection processCollection = ((RetrieveMultipleResponse)organizationSericeProxy.Execute(efr1)).EntityCollection;
                    if (processCollection.Entities.Count > 0)
                    {
                    }


    Regards Faisal

    Wednesday, December 2, 2015 1:22 PM