英文:
How do I get the display name of a hyperlink that comes from SharePoint in Power Apps?
问题
I am here to assist with the translation. Here's the translated content:
在SharePoint中的一个包含100多个项目的列表中,有5个超链接列,每个条目都包括URL地址和显示名称。
我正在为这个列表创建一个表单,允许用户编辑URL和显示名称,但似乎无法引用超链接列的显示名称。
我应该如何做?
超链接列的显示名称以蓝色显示。我需要在Power Apps中获取它们
英文:
In a list located in SharePoint, that has over 100 items, there are 5 hyperlink columns, with each entry in it including the URL address and a display name.
I am creating a form for this list that allows the user to edit both the URL and the display name, but I can't seem to reference the display name of hyperlink columns.
How do I do that?
The hyperlink columns have display names that were covered in blue. I need to get them in Power Apps
答案1
得分: 1
是的,这是可能的!不是使用内置的 SharePoint 连接器,而是使用标准(不是高级!)Office 365 Groups 连接器和 Graph API 进行 HTTP 请求。
让我们开始!
步骤 1
创建一个带有“超链接”列的“SharePoint 列表”。
创建一个新项,包括标题、URL 和 URL 描述:
目标是在 PowerApps 画布中显示 URL 描述,而不是标题。不幸的是,使用 SharePoint 连接器只返回标题和 URL,而不返回 URL 描述。例如,使用简单的画廊结果如下:
但有一个简单的解决方案!
步骤 2
在您的 Power Apps 画布中,创建一个新的连接,使用“Office 365 Groups”连接器。
步骤 3
在您的 Power Apps 画布中,打开“App > OnStart”并编写以下表达式(将“YOUR-SITE-GUID”替换为您的站点 GUID)。示例是为英语 Power Apps Studio 编写的(如果不是,请根据您的语言更改逗号和分号:https://learn.microsoft.com/en-us/power-platform/power-fx/global#formula-separators-and-chaining-operator)
要获取“YOUR-SITE-GUID”,您可以在浏览器中调用这个简单的 Web 请求:“https://your-tenant.sharepoint.com/sites/your-site/_api/site/id”(当然要使用您的租户和站点名称)。
Set(AllFavorites, Office365Groups.HttpRequest("https://graph.microsoft.com/v1.0/sites/YOUR-SITE-GUID/lists/Favorites/items?expand=fields", "GET", ""));
ClearCollect(
colAllFavorites,
ForAll(
Table(AllFavorites.value),
{
Title: Text(Value.fields.Title),
Url: Text(Value.fields.Bookmark.Url),
Description: Text(Value.fields.Bookmark.Description)
}
)
);
现在,您有一个新的集合(colAllFavorites
),其中包含标题、URL 和 URL 描述!
步骤 4
您可以创建一个新的画廊,将集合 colAllFavorites
用作画廊的数据源,并使用描述作为每个卡片的标题。这个画廊只是用来显示结果的(用于演示)。请随意根据您的项目进行调整(例如,使用下拉列表而不是画廊等)。
结论
“SharePoint GetItems”连接器不返回超链接列的描述。SharePoint API(Graph API 或 REST API)确实返回此值!在 Power Automate 中,可以使用“SharePoint HTTP 操作”,但在 Power Apps 中,使用“Office 365 Groups HTTP 操作”(标准连接器)更容易。
英文:
Yes, it's possible! Not with the built-in SharePoint connector, but with an HTTP request with the standard (not premium!) Office 365 Groups connector and the Graph API.
Let's go!
Step 1
Create a SharePoint list
with an hyperlink
column.
Create a new item with a Title, an URL and the URL Description:
The goal is to display the URL description, not the Title in a PowerApps Canvas. Unfortunately with the SharePoint connector, only the title and URL are returned. Not the URL description. For example, with a simple gallery the result is:
But there is a simple solution!
Step 2
In your Power Apps Canvas, create a new connection with the Office 365 Groups
connector.
Step 3
In your Power Apps Canvas, open App > OnStart
and write this expression (replace YOUR-SITE-GUID
by your site GUID). The sample is written for an English Power Apps Studio (it not, change the , and ; according to your language: https://learn.microsoft.com/en-us/power-platform/power-fx/global#formula-separators-and-chaining-operator)
To get YOUR-SITE-GUID
, you can call this simple web request https://your-tenant.sharepoint.com/sites/your-site/_api/site/id
in your browser (with your tenant and site name of course.)
Set(AllFavorites, Office365Groups.HttpRequest("https://graph.microsoft.com/v1.0/sites/YOUR-SITE-GUID/lists/Favorites/items?expand=fields", "GET", ""));
ClearCollect(
colAllFavorites,
ForAll(
Table(AllFavorites.value),
{
Title: Text(Value.fields.Title),
Url: Text(Value.fields.Bookmark.Url),
Description: Text(Value.fields.Bookmark.Description)
}
)
);
Now, you have a new collection (colAllFavorites
) with the title, URL and URL description!
Step 4
You can create a new gallery with the collection colAllFavorites
as the gallery's datasource and use the description as the title of each card. The gallery is only here to display the results (for this demonstration). Fell to free to adapt to your project (with a dropdown list instead of a gallery, etc.)
Conclusion
The SharePoint GetItems
connector does not return the description of an hyperlink column. The SharePoint API (Graph API or REST API) does indeed return this value! In Power Automate, SharePoint HTTP action
can be used but in Power Apps it's easier to use the Office 365 Groups HTTP action
(standard connector).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论