Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • suzyb 474 posts 932 karma points
    May 10, 2013 @ 18:02
    suzyb
    0

    Has ContentRelation.GetRelatedDocument changed

    As per this thread I was using ContentRelation.GetRelatedDocument to get the document that matched an old ID held in the CSV file that is being imported.  In version 2.3.2 this seemed to be working although I didn't really get a proper chance to fully test.  With version 2.3.3 I am getting the following exception with it.  The adapter, key name and key value are all set so I don't understand what object is not set.

    CMSImport content import: Error in third party event handler during  
    Importing event:System.NullReferenceException: Object reference not set 
    to an instance of an object.
       at .(String )
       at 
    CMSImport.Extensions.Relations.ContentRelation.GetRelatedDocument(String
     dataAdapter, String dataKeyName, Object dataKeyValue)
       at 
    SeevicCollege.ImportEvents.ContentImportEvents.ContentImport_RecordImporting(Object
     sender, RecordImportingEventArgs e) in 
    P:\BGNM169_SeevicCollege_Website_190612\solution\Forms\BLL\ImportEvents\Events.cs:line
     60
       at 
    CMSImport.Extensions.Import.ContentImport.FireRecordImporting(Document 
    doc, String dataSourceAlias, String dataKey, Object dataKeyValue, 
    IDataReader reader) 
                                

    The code that throws the error is

    Document d = ContentRelation.GetRelatedDocument(e.DataAdapter, e.DataKeyName, e.Items["Old Course Code"]);

    Has something changed with this.  Or has it working just been wishful thinking.

  • Richard Soeteman 4035 posts 12842 karma points MVP
    May 12, 2013 @ 07:00
    Richard Soeteman
    0

    Hi Suzy,

    The only difference between 2.3.2 and 2.3.3 is a new licensing dll. Can you check using a breakpoint if e.items["Old Course Code"] Exists?

    Thanks,

    Richard

  • suzyb 474 posts 932 karma points
    May 12, 2013 @ 14:01
    suzyb
    0

    It does exist.  I check it isn't null before doing that line but also checking in the debugger shows it is there and has a value.

  • Richard Soeteman 4035 posts 12842 karma points MVP
    May 13, 2013 @ 05:23
    Richard Soeteman
    0

    Is the following line returning null? Maybe you can post the complete event handler you are using?

    ContentRelation.GetRelatedDocument(e.DataAdapter, e.DataKeyName, e.Items["Old Course Code"]);
  • suzyb 474 posts 932 karma points
    May 13, 2013 @ 10:37
    suzyb
    0

    This is my event handler.  I've cut some lines from it as they just set property values in the same way as the two I've left in.  When debugging e.DataAdapter, e.DataKeyName and e.Items["Old Course Code"] all show as having a value.

    void ContentImport_RecordImporting(object sender, RecordImportingEventArgs e)
    {
    if (e.Items["Old Course Code"] != null)
    {
    Document d = ContentRelation.GetRelatedDocument(e.DataAdapter, e.DataKeyName, e.Items["Old Course Code"]);
    if (d != null)
    {
    d.getProperty("courseCode").Value = e.Items["Course ID"];
    d.getProperty("faculty").Value = e.Items["Faculty"];

    d.Save();

    umbraco.library.UpdateDocumentCache(d.Id);

    e.Cancel = true;

    }

    umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Notify, umbraco.BusinessLogic.User.GetUser(0), -1, "Updated Course Code " + e.Items["Old Course Code"] + " to " + e.Items["Course ID"]);
    }
    }

    This is the exception details

    System.NullReferenceException was unhandled by user code
    HResult=-2147467261
    Message=Object reference not set to an instance of an object.
    Source=CMSImport.Extensions
    StackTrace:
    at .(String )
    at CMSImport.Extensions.Relations.ContentRelation.GetRelatedDocument(String dataAdapter, String dataKeyName, Object dataKeyValue)
    at SeevicCollege.ImportEvents.ContentImportEvents.ContentImport_RecordImporting(Object sender, RecordImportingEventArgs e) in P:\BGNM169_SeevicCollege_Website_190612\solution\Forms\BLL\ImportEvents\Events.cs:line 60
    at CMSImport.Extensions.Import.ContentImport.FireRecordImporting(Document doc, String dataSourceAlias, String dataKey, Object dataKeyValue, IDataReader reader)
    InnerException:

     

  • suzyb 474 posts 932 karma points
    May 27, 2013 @ 15:07
    suzyb
    0

    Any idea why this isn't working.

  • Richard Soeteman 4035 posts 12842 karma points MVP
    May 27, 2013 @ 15:17
    Richard Soeteman
    0

    Hi Suzy,

     

    Sorry didn't see the reply which version of Umbraco are you using then I'll try myself

    Thanks,

    Richard

  • suzyb 474 posts 932 karma points
    May 27, 2013 @ 16:54
    suzyb
    0

    4.11.4

  • Richard Soeteman 4035 posts 12842 karma points MVP
    May 28, 2013 @ 15:50
    Richard Soeteman
    0

    Is it possible to send me the datasource also? [email protected] then I have all info.

    Thanks,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft