sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

List grouping by spfx computed column does not work - always group as not set

Open CarlVerret opened this issue 1 year ago • 5 comments

What type of issue is this?

Question

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Target SharePoint environment

SharePoint Online

What browser(s) / client(s) have you tested

  • [ ] 💥 Internet Explorer
  • [ ] 💥 Microsoft Edge
  • [X] 💥 Google Chrome
  • [ ] 💥 FireFox
  • [ ] 💥 Safari
  • [ ] mobile (iOS/iPadOS)
  • [ ] mobile (Android)
  • [ ] not applicable
  • [ ] other (enter in the "Additional environment details" area below)

Additional environment details

  • browser version
  • SPFx version
  • Node.js version
  • etc

Issue description

Having a custom spfx computed column in a list (wich displays true or false depending if two other fields are equal), when we select "Group by this column", the only group that is displayed is "Not set" (Non appliqué in french)

image

CarlVerret avatar May 03 '24 11:05 CarlVerret

Hi @CarlVerret, could you provide information about the calculated column and view grouping setting? I have checked it on my side and I can see the correct grouping label for a calculated column.

image

mkm17 avatar May 11 '24 16:05 mkm17

Hi Michał,

In fact I had to use a custom spfx field to compare if, under some circumstances two dates were equal or not, returning a simple Yes or No text value.

public onRenderCell(event: IFieldCustomizerCellEventParameters): void {

const monItemEnCours = event.listItem;

if ( ... ) // ... under some condition, set value to blank { event.domElement.innerText = ""; } else {

  const date_approb:Date =  monItemEnCours.getValueByName("approved date");
  const date_modif:Date = monItemEnCours.getValueByName("Modified");
  event.domElement.innerText =  date_modif <=date_approb  ? "Yes" : "No";
  
}

}

The display works perfectly in list's columns. But grouping by this column result in only "Non affecté" (not set in french) values. Even if the cell render produces values.

CarlVerret avatar May 13 '24 13:05 CarlVerret

@CarlVerret Unfortunately, it will not work like this. The SPFx field customizer does not change the value of a field; it just overrides the rendering of the column field. Maybe you can try using a calculated column formula instead. Try comparing both dates with conditional formulas: https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/bb862071(v=office.14)#conditional-formulas

If there are additional conditions, such as comparing both dates when the status of the items is 'Approved,' then simply add a nested IF statement.

mkm17 avatar May 13 '24 14:05 mkm17

The main reason we opted for a custom field is that there's no easy way to compare two dates natively with calculated columns. If there's one, we could figure it out ! This is something that is asked a lot about in many forums.

CarlVerret avatar May 13 '24 15:05 CarlVerret

I've reviewed the calculated column formula where I check the value of the Status column and compare the Modified date with my Approval DateTime column.

Of course, use ';' or ',' depending on the language on the site.

=IF(Status="Choice 2";IF(((Modified-[Approval DateTime])<0);"OK";"Not OK");"")

The effect is like this.

image

Of course, your case may be more complicated, and as you mentioned then other solutions may need to be considered.

mkm17 avatar May 13 '24 20:05 mkm17

Hello @CarlVerret, Thank you for bringing this issue to our attention. We will look into it and get back to you shortly. Could you please confirm if the issue still persists for you?

Amey-MSFT avatar May 26 '25 12:05 Amey-MSFT

yes it does !

CarlVerret avatar May 26 '25 13:05 CarlVerret

I've reviewed the calculated column formula where I check the value of the Status column and compare the Modified date with my Approval DateTime column.

Of course, use ';' or ',' depending on the language on the site.

=IF(Status="Choice 2";IF(((Modified-[Approval DateTime])<0);"OK";"Not OK");"")

The effect is like this.

image

Of course, your case may be more complicated, and as you mentioned then other solutions may need to be considered.

Sorry but substracting two dates to see if they're equals seems to be inacurate... it returns some slight difference even if they are the exact same ...

Image

CarlVerret avatar May 26 '25 13:05 CarlVerret

Hello @CarlVerret, We were able to reproduce the issue, and we are investigating it. We have logged this as a bug, and our engineering team will look into it. Thank you!

Amey-MSFT avatar Jun 09 '25 04:06 Amey-MSFT