Sep 04 2023 03:57 AM - edited Sep 04 2023 04:07 AM
Hi There,
I have a SP list that has a user directory pickup filed "requestor". I have updated the header which should Show "Request of: Leonard Jackson" at the Header when Add or Edit any data in that list. My code is following which is not working:
{
"debugmode": "true",
"elmType": "div",
"attributes": {
"class": "ms-bgColor-green"
},
"style": {
"width": "99%",
"border-top-width": "0px",
"border-bottom-width": "1px",
"border-left-width": "0px",
"border-right-width": "0px",
"border-style": "solid",
"margin-bottom": "16px"
},
"children": [
{
"elmType": "div",
"style": {
"display": "flex",
"box-sizing": "border-box",
"align-items": "center"
},
"children": [
{
"elmType": "div",
"attributes": {
"iconName": "MobileSelected",
"class": "ms-fontSize-42 ms-fontWeight-regular ms-fontColor-white",
"title": "Software Name"
},
"style": {
"flex": "none",
"padding": "0px",
"padding-left": "0px",
"height": "36px"
}
}
]
},
{
"elmType": "div",
"attributes": {
"class": "ms-fontColor-white ms-fontWeight-bold ms-fontSize-24"
},
"style": {
"box-sizing": "border-box",
"width": "100%",
"text-align": "left",
"padding": "21px 12px",
"overflow": "hidden"
},
"children": [
{
"elmType": "div",
"txtContent": "=if ([$Title] == '', 'New Item', 'Request of: ' + [$Requestor.DisplayName])"
}
]
}
]
}
Its not showing the username as following. But If the List filed "Requestor" is not a Directory pick, it works.
Sep 04 2023 04:33 AM
Solution@leonardbd Use .title instead of .DisplayName. I just tested and it is working fine for me. Also, make sure you are using correct internal name of your people picker column in JSON. You can get the internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?
{
"elmType": "div",
"attributes": {
"class": "ms-bgColor-green"
},
"style": {
"width": "99%",
"border-top-width": "0px",
"border-bottom-width": "1px",
"border-left-width": "0px",
"border-right-width": "0px",
"border-style": "solid",
"margin-bottom": "16px"
},
"children": [
{
"elmType": "div",
"style": {
"display": "flex",
"box-sizing": "border-box",
"align-items": "center"
},
"children": [
{
"elmType": "div",
"attributes": {
"iconName": "MobileSelected",
"class": "ms-fontSize-42 ms-fontWeight-regular ms-fontColor-white",
"title": "Software Name"
},
"style": {
"flex": "none",
"padding": "0px",
"padding-left": "0px",
"height": "36px"
}
}
]
},
{
"elmType": "div",
"attributes": {
"class": "ms-fontColor-white ms-fontWeight-bold ms-fontSize-24"
},
"style": {
"box-sizing": "border-box",
"width": "100%",
"text-align": "left",
"padding": "21px 12px",
"overflow": "hidden"
},
"children": [
{
"elmType": "div",
"txtContent": "=if ([$Title] == '', 'New Item', 'Request of: ' + [$Requestor.title])"
}
]
}
]
}
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
Sep 04 2023 04:37 AM
@leonardbd Here is the output while using JSON in my above response:
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
Sep 04 2023 08:46 PM
Thanks for the reply. It works just fine. But I have another list that has "Software Name" as a choice field instead of a Directory name pick. That isn't working. I guess for the SPACE in the filed name. Dont know how to write that in code.
here is it .. the last part of the Header code \
......
........
{
"elmType": "div",
"txtContent": "=if ([$Title] == '', 'New Item', 'Software Name: ' + [$Software Name])"
}
]
}
]
}
Sep 04 2023 10:37 PM
@leonardbd You have to use the internal name of software name column in JSON.
You can get the internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?
If internal name is SoftwareName then use [$SoftwareName].
Please consider giving a Like if my post helped you in any way.
Sep 05 2023 10:34 PM
Sep 06 2023 01:19 AM
@leonardbd Is it a single selection choice column or multiple selection choice column? Can you show us the screenshot of internal name of column you found and how you are using it in JSON now?
Also, this column should be available on list form in order to reference it in the SharePoint JSON form formatting.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
Sep 04 2023 04:33 AM
Solution@leonardbd Use .title instead of .DisplayName. I just tested and it is working fine for me. Also, make sure you are using correct internal name of your people picker column in JSON. You can get the internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?
{
"elmType": "div",
"attributes": {
"class": "ms-bgColor-green"
},
"style": {
"width": "99%",
"border-top-width": "0px",
"border-bottom-width": "1px",
"border-left-width": "0px",
"border-right-width": "0px",
"border-style": "solid",
"margin-bottom": "16px"
},
"children": [
{
"elmType": "div",
"style": {
"display": "flex",
"box-sizing": "border-box",
"align-items": "center"
},
"children": [
{
"elmType": "div",
"attributes": {
"iconName": "MobileSelected",
"class": "ms-fontSize-42 ms-fontWeight-regular ms-fontColor-white",
"title": "Software Name"
},
"style": {
"flex": "none",
"padding": "0px",
"padding-left": "0px",
"height": "36px"
}
}
]
},
{
"elmType": "div",
"attributes": {
"class": "ms-fontColor-white ms-fontWeight-bold ms-fontSize-24"
},
"style": {
"box-sizing": "border-box",
"width": "100%",
"text-align": "left",
"padding": "21px 12px",
"overflow": "hidden"
},
"children": [
{
"elmType": "div",
"txtContent": "=if ([$Title] == '', 'New Item', 'Request of: ' + [$Requestor.title])"
}
]
}
]
}
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.