如何根据类别更改Sharepoint日历中事件的颜色

如何根据类别更改Sharepoint日历中事件的颜色,sharepoint,sharepoint-online,Sharepoint,Sharepoint Online,我想有不同的背景颜色为不同的事件根据选定的类别 我正在使用的Json { “$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”, “elmType”: “div”, “txtContent”: “@currentField”, “style”: { “background-color”:

我想有不同的背景颜色为不同的事件根据选定的类别

我正在使用的Json

{
       “$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,
       “elmType”: “div”,
       “txtContent”: “@currentField”,
       “style”: {
          “background-color”: “=if(@currentField == ‘Out Of Office - LabOps’, ‘#2BBBAD’, if(@currentField == ‘Out Of Office - Tools & Monitoring’, ‘#4285F4’, if(@currentField == ‘Out Of Office - Billing & Provisioning’, ‘#aa66cc’, if(@currentField == ‘Out Of Office - Infrastructure’, ‘#bbdefb’, if(@currentField == ‘Out of Office - Networking Team’, ‘#cddc39’, ‘’ )))))”
       }
    }

没有改变背景颜色

有人能帮我吗?我也研究了这个解决方案,试图得到json,并对其进行了修改,但还是不走运 @Muhammad

我记得列格式仅在现代UI上可用。对于经典视图,请参考以下代码:

executeordelayuntlscriptload(CustomizeCalendarEvents,“SP.UI.ApplicationPages.Calendar.js”);
函数CustomizeCalendarEvents(){
//周或日日历视图
SP.UI.ApplicationPages.DetailCalendarView.prototype.renderGrids\u Old=
SP.UI.ApplicationPages.DetailCalendarView.prototype.renderGrids;
SP.UI.ApplicationPages.DetailCalendarView.prototype.renderGrids=
函数SP\u UI\u应用程序页面\u详细日历视图$renderGrids($p0){
这个。renderGrids_Old($p0);
一次计算(p0);
};
//月历视图
SP.UI.ApplicationPages.SummaryCalendarView.prototype.renderGrids\u Old=
SP.UI.ApplicationPages.SummaryCalendarView.prototype.renderGrids;
SP.UI.ApplicationPages.SummaryCalendarView.prototype.renderGrids=
函数SP\u UI\u应用程序页面\u摘要日历视图$renderGrids($p0){
这个。renderGrids_Old($p0);
一次计算(p0);
};
}
函数onCalendarGridsResented($p0){
console.log($p0);
var DivRenderingInfos=[];
$p0.forEach(v=>{DivRenderingInfos=DivRenderingInfos.concat(v.$5W_0)});
console.log(DivRenderingInfos);
var项目=[];
var clientContext=new SP.clientContext();
//获取日历列表
var calendarList=clientContext.get_web().get_lists().getByTitle(_spPageContextInfo.listTitle);
对于(var i=0;i