0

In a document library, I've included a field of type 'Number' in my custom content type.

At a particular point in my solution I increment this field by 1.

On certain items it will work, on certain items, the field in question isn't incremented.

By 'work', I mean I'm checking this field's value in the 'View Properties' dialog.

It's important to note that on the items it works for - I've noticed that the field has a value of 0 prior to incrementing it. On the items it doesn't work for, the value of the field is empty.

What I've Tried

  • I've removed and re-added the custom field to the content type through the UI several times.

This is a document library by the way, all of the documents I've looked at are of the same content type, same filetype, and are all approved. I can't seem to isolate the problem any further.

2
  • 1
    Are you modifying and deploy the content type? That could prove difficult and inconsistencies might be related.
    – eirikb
    Commented Nov 15, 2012 at 9:17
  • Thanks a lot for your response. Very valid point. I can't recall exactly when and what modifications were made to this content type but this field has been there since the start and this doesn't really explain the inconsistency of it. Thanks again. Commented Nov 15, 2012 at 9:21

1 Answer 1

1

Have you seen the log if it throws any error while trying to increment or just 'does not work', kindly check. And what if you set default value as 0 for the particular field? My guess is when it's empty or null and you try to increment the field then it's throwing null reference exception, so maybe initializing the field to 0 resolve the issue. Let me know if it works

1
  • Initializing it! Of course, I don't know why I'm thinking of this as if it's any other magical type of entity, I can't increment null I suppose. I'll try that and will mark your answer accordingly. Thanks a LOT. Appreciate it. Commented Nov 15, 2012 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.