1
Vote

System.NullReferenceException

description

Need some help getting this to work. Getting the below error....

System.NullReferenceException: Object reference not set to an instance of an object. at Slam.Configuration.XmlSqlDataMapping.GetTypeFields(String id, String typeName) at Slam.Events.DefaultEvents.Update(SPListItem listItem, IDataServices dataServices, IConfigurationManager configuration, ILogger logger, String eventPrefix)

I have no idea what this is referencing or where the null is. Below is my config file.


<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ConnectionStrings Default="SLAM">
    <add Name="SLAM" ConnectionString="Database=SharePointSLAM;Data Source=xxxxxx\xxxxxx;User Id=Slamuser;Password=slam123" />
</ConnectionStrings>

<DataMapping DataSchema="SLAM">
    <List Site="62041" Name="Master Document Register" ID="5C33DB50-D300-4B98-9311-358F3F38B844"  ActivationOrder="1">
        <Fields>
            <Field Name="Doc Title"     SqlType="varchar(255)" SPType="Text"        Required="false"></Field>
            <Field Name="Discipline"    SqlType="varchar(255)" SPType="Text"        Required="false"></Field>
            <Field Name="Doc Type"      SqlType="varchar(255)" SPType="Choice"      Required="false"></Field>
            <Field Name="Main Doc No"   SqlType="varchar(255)" SPType="Calculated"  Required="false"></Field>
        </Fields>
    </List>
</DataMapping>
</Configuration>

comments

brjenkins wrote Oct 10, 2013 at 11:41 AM

Try it without the ID value set of the List. From the error my guess is that the List is not being matched when getting the mapped fields for the list of the item being updated. With both the Name and ID being set then you might want to try the Name only first.

ibertrand wrote Oct 10, 2013 at 5:45 PM

That seemed to help. But now I am running into another issue. It is pulling nulls into the table. I have trying different things with the fields. How does the SPType affect the way information is read or entered into the database? Also, for the field name...does this need the be the display column name of the list or the internal name of the list? Example...Display name of the column is "Vendor Document Number" where the internal name is "Alt_x0020_Doc_x0020_Number".

brjenkins wrote Oct 10, 2013 at 6:51 PM

The SPType attribute doesn't affect the way information is read or stored. For the Name attribute of the field you can use either the display name or the internal name. If you have conflicting column names and you need to use the internal name you can still set the database column name properly using the Column attribute. If you are seeing nulls for a field that otherwise has values you can try setting Name to the internal name and set Column.

ibertrand wrote Oct 10, 2013 at 9:06 PM

No go on this. I have tried the display name and the internal name...still getting nulls where there should be data. Not sure why this works in a dev environment but not my production. What are some other considerations that I could be overlooking on this.

<Field Name="Alt_x0020_Doc_x0020_Number" Column="VendorDocNumberTest" SqlType="varchar(255)" SPType="Text" Required="false"></Field>

brjenkins wrote Oct 10, 2013 at 9:56 PM

Does the configuration page in the SLAM Control Panel show them as matched fields?

If other values are saving then the problem would still be that that field is not matching a field in the list item. Maybe it would be helpful to enable verbose logging and double check the SQL statements it is generating.

Edit your web.config and add as a child of <configuration>:
<system.diagnostics>
<switches>
  <add name="SLAMLogger" value="4" />
</switches>
</system.diagnostics>

After saving the SLAM.MessageLog table should contain information with the generated SQL being executed. I am assuming though that the insert or updates would not even contain the columns that are staying null.

ibertrand wrote Oct 11, 2013 at 3:04 PM

I tried added the entry to web.config and that went haywire and as this is production that wont work. The funny thing is that I got one column to work. It looks like it started working after I did an iisreset. Couldnt test it further because again this is production and folks are working.

Does this sound right to you?

I am going to add more columns and see if this starts working.

brjenkins wrote Oct 11, 2013 at 3:57 PM

After editing the slam.config it should be enough to go to the SLAM Control Panel to reload the config. If one did work after an iisreset then you changed the column name such that it now matches the field you're expecting it to match and the config had not been reloaded yet.