I am trying to create a page library with a ratings columns. I've been able to create other columns just fine, but the ratings one is giving me issues.

        var context = new SP.ClientContext(appUrl);
        var web = context.get_web();

        var lci = new SP.ListCreationInformation();

        var list = web.get_lists().add(lci);

        list.get_fields().addFieldAsXml('<Field' +
        ' Name="AverageRating"' +
        ' StaticName="AverageRating"' +
        ' DisplayName="$Resources:spscore,Ratings_AverageRatingFieldName;"' +
        ' Description="$Resources:spscore,Ratings_AverageRatingFieldDescription;"' +
        ' Group="$Resources:spscore,Ratings_FieldsGroup_15;"' +
        ' Type="AverageRating"' +
        ' Decimals="2"' +
        ' Min="0" Max="5"' +
        ' ShowInEditForm="FALSE"' +
        ' ShowInDisplayForm="FALSE"' +
        ' ShowInNewForm="FALSE"' +
        ' CanToggleHidden="TRUE"' +
        ' JSLink="sp.ui.reputation.js"' +
        ' SourceID="http://schemas.microsoft.com/sharepoint/v3">' +
           '<FieldRefs>' +
             '<FieldRef Name="RatingCount" />' +
             '<FieldRef Name="RatedBy" />' +
             '<FieldRef Name="Ratings" />' +
           '</FieldRefs>' +
        '</Field>', true, SP.AddFieldOptions.defaultValue);            

        context.executeQueryAsync(success, fail);

The site will build fine, but after I create a page and go back to the display page of the library I receive an error

TypeError: Unable to get property 'trim' of undefined or null reference

TypeError: Unable to get property 'trim' of undefined or null referenceTypeError: Unable to get property '_events' of undefined or null reference

UPDATE: So it appears that column is getting added, but there problem is that it is not displaying correctly. If I remove the column from the view then the list will load fine. When it's turned on is when I receive the error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.