SharePoint 2013 Calculated Field not working all the time - sharepoint

I have a form where I need to include a calculated field. I made a very simple test using a calculated field where the formula is "=ID". I just want to confirm that the value I'm getting in the view is the same as the ID of the record in the list.
I press NEW and create a new record. Then when I see the new record in the view, the first column is the ID (let's say 11), then some proper fields form the form and finally the calculated field that instead of showing me the value 11, it shows 0.
Then I follow the following steps:
I go to Settings, List Settings
Click on the calculated field to edit it (only edit it with no modifications) and press on OK (no modifications to the calculated field at all)
Go back to the list of records and now the calculated value shows me the value 11
I google it but no solution.. there is someone say that this issue is from the column ID, it mean 'when you initially save the item is that there is no value for "ID" yet' !
and this isn't my state, the column id is incremented normally when add new item.
Anyone can help me to identify with the calculated field does not shows 11 automatically after the record is saved?
or by follow another solution like using a workflow 2013..
Thanks a lot

You can not use [ID] in a Calculated Column formula.
I won't bother with the long technical explanation...
If it was possible, Microsoft would have added it to the list of Fields you can select when writing a Formula.
Workaround is to make a simple SharePoint Designer Workflow which kicks off on Item creation and saves the ID value to another Column.
You can then use that Column in your Calculated Formulas
If you're doing anything front-end.. jQuery.. CSR/JSlink.. the ID value is available in the attribute id of the Item TableRow (TR) as x,id,y
so you can get the id with
var ID={element}.getAttribute('id')[1]
Update #1 - example code used:
="<a href='/sites/ru1/Lists/ao26c/DispForm.aspx?ID='
target='_blank'><img src= '_layouts/images/blank.gif'
onload= ""var row=this;
while(row.tagName!='TR'){row=row.parentNode};
this.parentNode.href+=row.‌​getAttribute('id').split(',')[1];
"">Открыть</a>"

Related

How do I use a power apps form for a lookup column?

I have a SharePoint List (say "List-A") with plenty of columns, some of which are lookup columns.
These are just used to construct a choice columns, where the items in the choice drop down are the items of a column in a different List ("List-B").
I have used the function on SharePoint to integrate List-A with Power Apps Form. This creates a Power Apps form that is readily available.
For the Lookup choice columns, I have added List-B as the data source, and am using the items from the correct column as items in the choice that is linked to the lookup column. This correctly populates the drop down menu as expected.
Now when I publish this form and fill it from sharepoint (it pops up as it should hafter clicking New in the List view) I can fill the entire form and submit with no issue. However all the lookup columns remain blank, as if the form returned a null value instead of the selected.
I have both datasources set up:
The update property of the datacard connecting to the SharePoint List is equal to the Selected of the datacard containing the combobox (combobox is called DataCardValue43).
The items property of the combobox is equal to the correct column of List-B.
As an alternative solution, I have attempted to make a different column that is just one line of text. For this column, I have made a combobox once again setting the items property to the column in List-B. The intention was to return the selected value as a string. It was attempted thus:
where combobox1 once again manages to give the correct options in the drop down box but returns only Null.
To study it further, I have made a power apps flow that takes Create New Sharepoint List object as input. Here I see that the values are indeed Null
The one called "Return" is the text column that I made, and the other being the lookup column. I do notice that the Lookup column isn't called Value, but id. I don't know what to do with that information though.
I really just want to have a column in my power apps form that lets you choose and the choices are values from a column in a different List. What do I do, and why doesn't what I've already done work?
Thank you.
Please follow the steps below to solve the issue.
1: Add a Lookup column in SharePoint List.
2: Open that list in Power Apps by using the Customise Forms Option From SharePoint.
3: The Item property of Lookup field will be by default as follow:
Choices([#'CustomisingSharePointList'].LookupColumnListName)
4: There is no need to change/delete the lookup field with any custom dropdown or combo box. This is the point, where you are doing mistake by adding a custom combobox and replacing the original Lookup dropdown. If you want to change datasource, apply filter or sort the data, you can do all these thing to the same original lookup column.
e.g I have applied filter and sort functions to the existing data:
Sort(Filter(Choices([#'CustomisingSharePointList'].'LookupColumnListName'), Value in Filter(LookupColumnListDataSoure,Progress.Value = "Open").ID),Id)
5: When you will publish the list, it will work fine.
Note:
CustomisingSharePointList: List in which we have added a lookup column.
LookupColumnListName: List to which the lookup column actually belongs to.
LookupColumnListDataSoure: You need to add the original list as data source in power apps to use the above filter. This step is optional and applicable only if you apply filter like I did in step 4

Sharepoint List Calculated Column isn't displaying correctly

My SharePoint List has a calculated column based on the item ID which is auto generated.
It's a simple text function ="SR-"&TEXT(ID,"0000"), which works fine, but the last few items added are all showing the value SR-0000, despite ID being 457 and 458.
Any ideas?
It works well in my environment.
Try to use rest to get the current item, and check what is the value saves in the column.
The displayed data may be changed by other logic, such as JSON formatting.

Getting the greatest value for a field for all records

For our Employee records within NetSuite, we have a custom field called "Employee Number" with an ID of custentity1. I've created a workflow that will automatically create a new employee record and populate various fields but the one I'm having difficulty with is the Employee Number field. All I want to do is to grab the largest employee number there is out of all of the Employee records and add one to it for the new employee record.
The Employee Number field is a free-form text field so I know I'll have to use TO_NUMBER, but anytime I try and reference {custentity1} I keep getting an error saying that field is not found.
UPDATE: I've created a new custom field for our employee records called "Employee No." with an ID of custentity_employeenumber. I've also created a javascript file with the following:
function getMaxEmployeeNumber(){
var empNumber = nlobjSearchColumn('custentity_employeenumber', null, 'max');
return empNumber;
}
But how to do I get this to work with my records?
NetSuite does have an auto-numbering mechanism built in to its native functionality that most of our customers use for this exact purpose. Is there a special reason this functionality is not being leveraged? This functionality is accessible at Setup > Company > Auto-generated Numbers.
I do not work much with workflows, so I do not know if this same functionality is possible there, but here is how I would solve this in SuiteScript:
Create User Event script that is executed on Before Submit Create event for Customer records
Create a Customer search that has a Search Column for custentity1 with a summary type of max
new nlobjSearchColumn('custentity1', null, 'max');
Running this search should give you 1 result, which is the maximum customer number. You can then just add 1 to it.
You could create a similar Saved Search in the UI to see what the result set looks like.
This will only really work if the field is a Number, not Text. I would suggest changing the field to an Integer field if you know that it will always be a number. This may clear out existing data, so first you could export all customers and their number to Excel and then do a CSV import after changing the field.
How are you looking for the last employee in a workflow?
I know this can be done in js:
Search employees - returns max 1000
For number of employees give me the custentity1 of the last one - nlapiLookupfield('employee',employees[employees.length],'custentity1')
Add +1 and save on new record
If you use this search column
nlobjSearchColumn('custentity1', null, 'max');
You can also sort it in decreasing value so that the first result is always the max. Something like
nlobjSearchColumn('custentity1', null, 'max').setSort(true);

In SharePoint, how can the "Issue ID" column of an issues list be included in the detail form (DispForm.aspx) and/or alert emails?

We've created a pretty standard issue tracking system based off of SharePoint's template with just a few extra columns. On the list view (AllItems.aspx), the first column is called "Issue ID" and has a number. Our developers and QC use that number in discussions. However, that number doesn't seem to want to show up on the detail form (DispForm.aspx) nor in the alert email.
Can this field be included in at least one of these communication methods? If so, how?
Thank you.
We did something similar and used workflow via SharePoint Designer to copy the ID field into a field called "Issue Number". The workflow gets triggered automatically on Create / Edit (we included edit because the field can be modified by the user on the edit form and if that happens we want the number refreshed with the actual ID).
Before you create the workflow in SharePoint Designer, you need to add a column called "Issue Number" to the list you want to tweak.
List item
Open Sharepoint Designer
List item
Click File New -> Workflow
Give a name for the workflow
a. select the list from the dropdown
b. Uncheck Allow this workflow to be manually started and check automatically start on new and change then press Next
Give the step a name like "Assign Issue Number"
Create a Condition
If Compare a field -> If Issue Number not equals Current_Item:ID
Create an Action
Update List Item -> Set Issue Number to Current_Item:ID
Press Finished and test out by creating a new issue.
*The Issue Number will appear on the form and if you have emails setup to notify on assignment it will appear in the reassigned template.
*It will not appear in the created email confirmation because the workflow gets triggered after that email was executed.
I just added the issue ID using a total of 4 characters. Create a new column, set it to a Calculated column, in the formula type [ID]. Voila! The ID is now in your detail view.
The ID link returned the for me, however, the work around which sufficed for me was to enter 'Created' in the Calculated Column formula and ensure it is set at date and time. That then creates a unique idenity (unless you receive more than 1 list update per minute) than can be viewed in the email alert message

SharePoint: Calculated Column Values Disappear When Editing List Item. Any ideas?

I have a calculated column in a custom SharePoint 2007 list, with the following formula:
=CONCATENATE("IR-",[ID],"-",LEFT(UPPER([Title]),25))
If an item is created in the list, everything is fine, however, when an item is updated the [ID] column is no longer in the calculated column for that item.
So, on creation: "IR-40-TheTitleIsHere", but after edit, it is, "IR--TheTitleIsHere".
Anyone have some insight on why this would be happening?
I confirm the behavior mentioned above. Any Add/Edit will wipe out the [ID] portion. If you edit the column in the list and update the formula, it will update ALL list items to be correct (until you do an edit on the item).
I found this post that mentions the same problem.
Sounds like the only solution would be to make a simple workflow using SharePoint Designer that would update a text field in your list.
I had an issue similar a while back. Through other blogs and experts, I discovered that the [ID] column should not be used in a calculated column because it wreaks havoc and causes many errors. Sorry - remove the ID column and you should be fine.
This question is a little old, but I had the same issue and found a solution for it. It is a pretty specific fix and won't help everyone -- it involves using javascript in a content editor web part to update the calculated field.
This site -- http://blog.pathtosharepoint.com/2008/09/01/using-calculated-columns-to-write-html/ -- gives an example of how to use javascript in the same manner that I used it.. the important block of code is the first while loop. The point is to grab the out of box ID column from the list and update whatever calculated field needs the ID.
In my case I had a URL in a calculated field that required the ID as a parameter.. of course that wouldn't work normally because you can't put the ID in a calculated field. What I did was I put "?ID=null" in the ID parameter of my calculated field's url, I then replaced that with the ID that was retrieved using javascript.. so whenever the page is loaded, the js kicks off and updates all of the URLs to have the correct ID.
I know this is very old but I couldn't find a newer version of the question anywhere else and the answer above from ferr solved the problem for me but isn't very clear so I thought I'd update it.
This assumes that you want to use the ID in the output HTML (for example within a link), I think this is fairly common.
Using the javascript from the pathtosharepoint link I added in the following to get the id with an if statement for safety:
if (HTMLregexp.test(CellContent)) { //original pathtosharepoint line
if (NodeSet[i].parentNode.getAttribute("iid")){
var SPID = NodeSet[i].parentNode.getAttribute("iid").split(",")[1];
CellContent = CellContent.replace("SPIDReplace", SPID)
}
NodeSet[i].innerHTML = CellContent; //original pathtosharepoint line
This is put in the while loop of the latest pathtosharepoint fix at time of writing. This works for me on SharePoint 2010.
Note: Include the string "SPIDReplace" in your calculated column to get it replaced by the item ID.
pathtosharepoint page: http://blog.pathtosharepoint.com/category/calculated-columns/
pathtosharepoint code: http://pathtosharepoint.com/Downloads

Resources