Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
1  
Are you modifying and deploy the content type? That could prove difficult and inconsistencies might be related. –  eirikb Nov 15 '12 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. –  DeeMac Nov 15 '12 at 9:21
add comment

1 Answer

up vote 1 down vote accepted

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

share|improve this answer
    
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. –  DeeMac Nov 15 '12 at 9:28
    
Sorted. Thanks again. –  DeeMac Nov 15 '12 at 9:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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