【问题标题】:Why SharePoint remote event receiver calls Azure Function six times?为什么 SharePoint 远程事件接收器调用 Azure Functions 六次?
【发布时间】:2023-02-17 22:19:36
【问题描述】:

我在 SharePoint 中有一个列表,其中附加了一个同步事件接收器,用于响应列表项 (ItemUpdating) 的更改事件。还有一个事件接收器调用的 Azure 函数。该函数验证字段。问题是,如果字段通过验证,则函数运行一次,但如果验证未通过,则事件接收器运行函数六次。

using namespace System.Net;

param($Request, $TriggerMetadata);
Write-Output "Function started.";

$xmlDocument=[xml]$Request.Body;
$ListItemTitle = $xmlDocument.Envelope.Body.ProcessEvent.properties.ItemEventProperties.AfterProperties.KeyValueOfstringanyType[1].Value.InnerText;
$listName = $xmlDocument.Envelope.Body.ProcessEvent.properties.ItemEventProperties.ListTitle;

Write-Output $ListItemTitle;
Write-Output $listName;

$responseBody = @'
<s:Envelope
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <ProcessEventResponse
            xmlns="http://schemas.microsoft.com/sharepoint/remoteapp/">
            <ProcessEventResult
                xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <ChangedItemProperties
                    xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
                <ErrorMessage>Validation Error!</ErrorMessage>
                <RedirectUrl i:nil="true"/>
                <Status>CancelWithError</Status>
            </ProcessEventResult>
        </ProcessEventResponse>
    </s:Body>
</s:Envelope>
'@;

if($ListItemTitle -eq "BadTitle"){
    Write-Output "Validation error!";
    Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
        Body = $responseBody;
        ContentType = "text/xml";
        StatusCode = [HttpStatusCode]::OK;
    });
}
else{
    Write-Output "Validation passed.";
    Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
        StatusCode = [HttpStatusCode]::OK;
    });
}

如何在验证失败时让函数运行一次?

【问题讨论】:

    标签: azure-functions sharepoint-online event-receiver


    【解决方案1】:

    我在 itemAdding 和 itemUpdating 上都有同样的问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-07
      • 1970-01-01
      • 2020-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多