columns dereferencing in SharePoint's calculated column

核能气质少年 提交于 2019-12-31 05:12:24

问题


I want to use the simple formula:

="FIX_" & [ID]

The issue with this formula occurs when I confirm the calculated function, the formula appears to revert back to:

="FIX_" & ID

The problem is now that these are no longer referencing the [ID] column so the result returns

"FIX_"

for all records. This does work for the first record entered but any other subsequent entries display this error.

Is this a known issue?


回答1:


So you only want to display the link in a VIEW.

You can then use HTML/JavaScvript in a Calculated Column to extract the correct ID from the HTML TR table row and create the href attribute.

Create a Calculated Columns, and set the datatype to Number!

Paste the Formula (as is, including & characters, line breaks will be ignored):

="<div ""style=text-align:left""><a><img src=""/_layouts/images/blank.gif"" onload=""{"
&"var row=this;while(row.tagName!='TR'){row=row.parentNode;}"
&"var ID=row.id.split(',')[1];"
&"this.parentNode.href='v://database//FIX_'+ID;"
&"}"">database folder</a></div>"

Note: the outer div is added because a Number column is aligned to the Right.

This only works in VIEWS! Not on FORMS!

See http://ViewMaster365.com/#/How for more details




回答2:


The [ ] notation has got nothing to do with it.. [ ] are only required if fieldnames contain spaces.. As you experienced SharePoint will strip those [ ] on save.

why ID is not listed as a usable Field for Formulas

You can not use the ID in a calculated column because on first Item creation the Calculated Column Formula is processed before the item is written to the database and gets its ID.

Thus ID is 0 for newly created items

When an Item is changed/updated the ID is correctly populated and used with the correct value in Formulas.

Work-around is to create a Workflow (which runs after Item creation) that gets the ID and writes it to another field, and use that in your Formula

or have the workflow changes something else in any field so an item update is forced; reading the Title and write it back in the same field will do.



来源:https://stackoverflow.com/questions/28986458/columns-dereferencing-in-sharepoints-calculated-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!