SOLVED

Adding JSON inside my "Format view" is not having any effect.

%3CLINGO-SUB%20id%3D%22lingo-sub-320892%22%20slang%3D%22en-US%22%3EAdding%20JSON%20inside%20my%20%22Format%20view%22%20is%20not%20having%20any%20effect.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-320892%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20custom%20list%20inside%20our%20sharepoint%20online%20classic%20team%20site.%20now%20the%20custom%20list%20has%20a%20field%20named%20%22SiteAutomaticallyCreated%22%20of%20type%20%22Single%20Line%20of%20text%22%20which%20can%20have%20values%3B%20(null%2C%20No%20or%20Yes).%20and%20i%20want%20to%20redirect%20the%20users%20when%20they%20click%20on%20the%20list%20item%20title%2C%20to%20either%20the%20normal%20display%20form%20if%20the%20%22SiteAutomaticallyCreated%22%20%3D%20No%20%2C%20OR%20to%20redirect%20the%20user%20to%20a%20sub-site%20if%20the%22SiteAutomaticallyCreated%22%20%3DYes.%3C%2FP%3E%3CP%3ESo%20inside%20my%20list%20view%20%26gt%3B%26gt%3B%20I%20click%20on%20%22Format%20view%22%20%26gt%3B%26gt%3B%20i%20added%20this%20json%3A-%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%7B%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%26nbsp%3B%20%22%24schema%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fcolumn-formatting.schema.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fcolumn-formatting.schema.json%3C%2FA%3E%22%2C%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%26nbsp%3B%20%22elmType%22%3A%20%22a%22%2C%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%26nbsp%3B%20%22txtContent%22%3A%20%22%40currentField%22%2C%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%26nbsp%3B%20%22attributes%22%3A%20%7B%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22target%22%3A%20%22_blank%22%2C%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22href%22%3A%20%22%3Dif(%5B%24SiteAutomaticallyCreated%5D%20%3D%3D%20'Yes'%2C%20'https%3A%2F%2F****.sharepoint.com%2Fsites%2F**%2F**%2F'%2C'https%3A%2F%2F***.sharepoint.com%2Fsites%2F***%2F**%2FLists%2FProjects%2FDispForm.aspx%3FID%3D')%20%2B%20%5B%24ID%5D%22%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%26nbsp%3B%20%7D%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%7D%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eas%20follow%3A-%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20437px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F69026iBE18BC012AB1DD69%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22fv.png%22%20title%3D%22fv.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20currently%20when%20i%20click%20on%20any%20item%20i%20will%20be%20redirected%20to%20the%20display%20form.%20and%20i%20am%20already%20showing%20the%20SiteAutomaticallyCreated%20field%20inside%20the%20list%20view.%3C%2FP%3E%3CP%3Eso%20can%20anyone%20advice%20on%20this%20please%3F%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-320892%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ELists%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-321400%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20JSON%20inside%20my%20%22Format%20view%22%20is%20not%20having%20any%20effect.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-321400%22%20slang%3D%22en-US%22%3E%3CBLOCKQUOTE%3E%3CHR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F5628%22%20target%3D%22_blank%22%3E%40Matti%20Paukkonen%3C%2FA%3E%26nbsp%3Bwrote%3A%3CBR%20%2F%3E%3CP%3EIf%20you%20need%20changes%20only%20to%20Title%20column%2C%20just%20format%20only%20the%20Title%20column.%20Your%20code%20is%20actually%20working%20correctly%20on%20column%20formatting.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EColumn%20formatting%20can%20be%20found%20on%20column%20settings.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20420px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F69095iF957A127CF14CB5F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Capture.PNG%22%20title%3D%22Capture.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CHR%20%2F%3E%3C%2FBLOCKQUOTE%3E%3CP%3Ethanks%20for%20pointing%20this%20out%2C%20i%20thought%20i%20need%20to%20apply%20this%20to%20the%20view%20format.%20now%20my%20code%20is%20working%20well..%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-321292%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20JSON%20inside%20my%20%22Format%20view%22%20is%20not%20having%20any%20effect.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-321292%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F233354%22%20target%3D%22_blank%22%3E%40john%20john%3C%2FA%3E!%20The%20Json%20field%20is%20only%20for%20conditional%20formatting.%20You%20tried%20to%20manipulate%20the%20masterpage%20settings%20and%20thus%20it%20redirected%20to%20the%20original%20displayform.%20The%20modern%20ux%20%2F%20classic%20settings%20are%20not%20open%20for%20being%20set%20by%20users.%20Thats%20an%20admin%20thing%20to%20do.%20For%20this%20you%20have%20the%20central%20administration%20settings%20in%20your%20sharepoint%20online%20center%20in%20office%20365.%20Or%20you%20can%20manipulate%20the%20masterpage%20and%20insert%20a%20new%20choice%20button%2C%20whether%20user%20should%20be%20able%20to%20change%20the%20ux%20(%3F%3F%3F)%20.%20Good%20look%20and%20greets%2C%20Eva.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-321139%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20JSON%20inside%20my%20%22Format%20view%22%20is%20not%20having%20any%20effect.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-321139%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20you%20need%20changes%20only%20to%20Title%20column%2C%20just%20format%20only%20the%20Title%20column.%20Your%20code%20is%20actually%20working%20correctly%20on%20column%20formatting.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EColumn%20formatting%20can%20be%20found%20on%20column%20settings.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20420px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F69095iF957A127CF14CB5F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Capture.PNG%22%20title%3D%22Capture.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Valued Contributor

I have a custom list inside our sharepoint online classic team site. now the custom list has a field named "SiteAutomaticallyCreated" of type "Single Line of text" which can have values; (null, No or Yes). and i want to redirect the users when they click on the list item title, to either the normal display form if the "SiteAutomaticallyCreated" = No , OR to redirect the user to a sub-site if the"SiteAutomaticallyCreated" =Yes.

So inside my list view >> I click on "Format view" >> i added this json:-

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "target": "_blank",
    "href": "=if([$SiteAutomaticallyCreated] == 'Yes', 'https://****.sharepoint.com/sites/**/**/','https://***.sharepoint.com/sites/***/**/Lists/Projects/DispForm.aspx?ID=') + [$ID]"
  }
}

 

as follow:-

fv.png

 

But currently when i click on any item i will be redirected to the display form. and i am already showing the SiteAutomaticallyCreated field inside the list view.

so can anyone advice on this please?

Thanks

4 Replies

If you need changes only to Title column, just format only the Title column. Your code is actually working correctly on column formatting.

 

Column formatting can be found on column settings.

Capture.PNG

 

 

Hi @john john! The Json field is only for conditional formatting. You tried to manipulate the masterpage settings and thus it redirected to the original displayform. The modern ux / classic settings are not open for being set by users. Thats an admin thing to do. For this you have the central administration settings in your sharepoint online center in office 365. Or you can manipulate the masterpage and insert a new choice button, whether user should be able to change the ux (???) . Good look and greets, Eva.

Best Response confirmed by john john (Valued Contributor)
Solution

@Matti Paukkonen wrote:

If you need changes only to Title column, just format only the Title column. Your code is actually working correctly on column formatting.

 

Column formatting can be found on column settings.

Capture.PNG

 

 


thanks for pointing this out, i thought i need to apply this to the view format. now my code is working well..

@john john Is there a way I could do that with the [ID] column?  I could have Title be say renamed to or a new column "Site Number: XXX" where XXX is the item ID reference from the ID column.