locked
Crm.Sdk.OrganizationServiceFault - Context not currently tracking the entity RRS feed

  • Question

  • Trying to troubleshoot an SSIS job that first runs a simple select query against two entities . Then a script component is called to update a field on the entities based on the result set .

    The job runs fine locally. When placed on our QA SSIS server and still pointed to a developer org it runs fine. However when pointed to a QA organization the "Context not currently tracking the entity ... " is thrown

    Below is the code snippet of the method that is failing . It only fails when we have the job run against our QA org.

    publicoverridevoidInput0_ProcessInputRow(Input0BufferRow)

        {

           

    if(!Row.EntityId_IsNull && !Row.CreatedOn_IsNull)

            {

               

    Entityentity = newEntity();

                entity.Id = Row.EntityId;

                entity.LogicalName = Row.EntityName;

                entity.Attributes =

    newAttributeCollection();

                entity.Attributes.Add(

    newSystem.Collections.Generic.KeyValuePair<string, object>("aprv_cycletime", (DateTime.Now - Row.CreatedOn).Days));

               

    //client.Update(entity); 


                 

               context.Attach(entity);

                context.UpdateObject(entity);

                context.SaveChanges();

               

    if(!context.IsAttached(entity))

                {

                    context.Attach(entity);

                }

          

            }

        }


    Robert

    Friday, January 31, 2014 3:33 PM

All replies

  • Hi,

        If the code works fine for one server, so the issue could be due to security of SQL server. Have you checked the rights of the user account running the SSIS package?


    Hope this helps.
     
    -----------------------------------------------------------------------
     Minal Dahiya
    blog : http://minaldahiya.blogspot.com.au/

     
    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    Sunday, February 2, 2014 4:19 AM
  • That was my first initial question but it seem to be executing the first part of the job ok, which is querying the CRM database.

    What permissions could I look for that might be a problem?


    Robert

    Sunday, February 2, 2014 5:27 AM
  • Hi Robert,

         In terms of security, here is few things to check:

    1) Is the user running the SSIS package, a valid CRM user?

    2) Is the user running the SSIS package, have enough rights in CRM?

         For testing purposes, please check if the same code works fine with system admin rights in CRM and use the same system admin account for SSIS package. If that works then you would need to create a role which gives the user enough rights to perform the above task.


    Hope this helps.
     
    -----------------------------------------------------------------------
     Minal Dahiya
    blog : http://minaldahiya.blogspot.com.au/

     
    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    Sunday, February 2, 2014 10:30 AM
  • Where can I check to see what account is running the package? This job is being run on a dedicated SSIS server and being triggered by a scheduled (UC4) job. The UC4 account is a user with system admin rights in CRM .


    Robert

    Monday, February 3, 2014 4:50 PM