locked
Dynamics Crm 2015 Update - Plugins Error Casting to DateTime RRS feed

  • Question

  • Hi There, 

    i had created a plugin, in this plugin it will retrieve multiple records from another entity, and do some calculations, what i want is when i create a new record i have to specify a date from and a date to, the retrieve multiple will retrieve record created on between date from and date to, the problem i have is there is an error when i cast a date attribute to DateTime,

    Currently i'm using an CRM nuget package version 7.0.0.0, which means there is no CRMDateTime or anything similar. 

    DateTime DateFrom = (DateTime)currentRecord["publisher_datefrom"]; //Casting Error
    
    DateTime DateTo = (DateTime)currentRecord["publisher_dateto"]; //Casting Error
    
    DateTime CreatedOn = (DateTime)currentRecord["createdon"]; //Casting Error
     

    another case i'm facing a problem in the Visual Studio, when i debug and track my code i'm using w3wp.exe process for debugging, the break points will appear white and have a warning symbol, if i navigate to debug from the ribbon and then window then modules, non of the modules and symbols is loaded, it appears either "Skipped loading symbol" or "cannot load symbol".

    any help would be appreciated.

    Kind Regards


    Tuesday, January 19, 2016 12:36 PM

All replies

  • Hi

    I suggest checking if the attribute is contained in the record.

    if(currentRecord.Attributes.Contains("publisher_datefrom"))

    Tuesday, January 26, 2016 8:00 AM
  • Hi,

    I agree with F.Kuyler, and would like to add that if you get a casting error, what error do you get?

    Regards


    Rickard Norström Developer CRM-Konsulterna
    http://www.crmkonsulterna.se
    Swedish Dynamics CRM Forum: http://www.crmforum.se
    My Blog: http://rickardnorstrom.blogspot.se

    Tuesday, January 26, 2016 11:28 AM
  • You can use tracing instead of debugging:-

    http://www.powerobjects.com/2015/04/02/dynamics-crm-spring-wave-update-1-theming/


    Regards Faisal

    Thursday, January 28, 2016 8:46 AM