locked
Code error for plugin are you missing a using directive or an assembly reference RRS feed

  • Question

  • Hi All;

    I am getting following error for the below code

    object doesn't contain a definition for 'ActualdurationMinutes 'and no extension method 'ActualdurationMinutes 'accepting a forst argument of type object could be found (are you missing a using directive or an assembly reference)

    Any help much appreciated

    Thanks

    private void CalcProjectActivities(XrmServiceContext xrm, ITracingService tracingService, Entity reldEntity)
            {
                 //tracingService.Trace("Get activity");
               //ActivityPointer activity = xrm.ActivityPointerSet.FirstOrDefault(ac => ac.ActivityId == new Guid(reldEntity["activityid"].ToString()));
                tracingService.Trace("Get all related activities");
                IQueryable activities = xrm.ActivityPointerSet.Where(ac => ac.RegardingObjectId != null &&
                    ac.RegardingObjectId.Id == ((EntityReference)reldEntity["regardingobjectid"]).Id &&
                    ac.ActualDurationMinutes != null && ac.StateCode.Value == ActivityPointerState.Completed);
    
    
    
                if (activities != null)// && activity != null)
                {
                    int totalSum = 0;
                    //ActualDurationMinutes a  = new ActualDurationMinutes();
    
    
    
                    foreach (var a in activities)
                    
                    {
    
                        totalSum += a.ActualDurationMinutes.Value;
                    }
                }
            }


    Pradnya07

    Thursday, January 16, 2014 3:24 PM

All replies

  • check it by :

       foreach (var a in activities)
                    
                    {
                        if(a.Contains("ActualDurationMinutes"))
                        totalSum += a.ActualDurationMinutes.Value;
                    }



    Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    Friday, January 17, 2014 4:23 AM
  • Hi

    Thanks for your reply

    I did used your code but comes with below error

    Any help much appreciated

    Thanks

    ************************

    private void CalcProjectActivities(XrmServiceContext xrm, ITracingService tracingService, Entity reldEntity)
            {
                 //tracingService.Trace("Get activity");
               //ActivityPointer activity = xrm.ActivityPointerSet.FirstOrDefault(ac => ac.ActivityId == new Guid(reldEntity["activityid"].ToString()));
                tracingService.Trace("Get all related activities");
                IQueryable activities = xrm.ActivityPointerSet.Where(ac => ac.RegardingObjectId != null &&
                    ac.RegardingObjectId.Id == ((EntityReference)reldEntity["regardingobjectid"]).Id &&
                    ac.ActualDurationMinutes != null && ac.StateCode.Value == ActivityPointerState.Completed);



                if (activities != null)// && activity != null)
                {
                    int totalSum = 0;
                    //ActualDurationMinutes a  = new ActualDurationMinutes();

                    foreach (var a in activities)
                    {
                        if (a.Contains("ActualDurationMinutes"))
                            totalSum += a.ActualDurationMinutes.Value;
                    }





                    /*
                    foreach (var a in activities)
                    
                    {

                        totalSum += a.ActualDurationMinutes.Value;
                    }
                
            */
                }


    Pradnya07

    Friday, January 17, 2014 9:29 AM
  • if it an plugin,

    then in my idea firstly write an console application application and

    Try to debug your code  and find activities  type is of which type in runtime ,then cast this in your code.


    Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    Wednesday, January 22, 2014 5:27 AM