From 161642bbb0052c9673e711c26365f55953ee41fa Mon Sep 17 00:00:00 2001 From: Marco Zamana Date: Fri, 6 Jun 2025 13:00:39 +0200 Subject: [PATCH 1/2] Update PowerFx formula --- OnGeneratedResponse/swap-citations.yml | 129 +++++++++---------------- 1 file changed, 46 insertions(+), 83 deletions(-) diff --git a/OnGeneratedResponse/swap-citations.yml b/OnGeneratedResponse/swap-citations.yml index 416cd342..15498e8b 100644 --- a/OnGeneratedResponse/swap-citations.yml +++ b/OnGeneratedResponse/swap-citations.yml @@ -2,7 +2,7 @@ kind: AdaptiveDialog beginDialog: kind: OnGeneratedResponse id: main - condition: =CountRows(System.Response.Citations)>0 + condition: =CountRows(System.Response.Citations) > 0 actions: - kind: SetVariable id: setVariable_wtNwaw @@ -12,101 +12,64 @@ beginDialog: - kind: SetVariable id: setVariable_9IFwdP variable: Topic.CitationsSnip - value: |- + value: | =With( - {CitationsTable: System.Response.Citations}, + { CitationsTable: System.Response.Citations }, Concat( ForAll( - Sequence(CountRows(CitationsTable)), - Value - ), - With( - { - currentRecord: Index( - CitationsTable, - Value - ) - }, - //begin logic - "[" & Text(Value) & "]: " & If( - IsBlank(currentRecord.Url), + Sequence(CountRows(CitationsTable)) As seqItem, + With( + { currentRecord: Index(CitationsTable, seqItem.Value) }, + "[" & Text(seqItem.Value) & "]: " & If( - Left( - currentRecord.Name, - 8 - ) = "https://", - Substitute( - currentRecord.Name, - " ", - "%20" - ), - Substitute((Topic.externalWebsiteURL & currentRecord.Name), " ", "%20") & - // + IsBlank(currentRecord.Url), If( - // check if cited source is a PDF - EndsWith(currentRecord.Name,".pdf"), - // add page for PDFs - "#page=" & Mid( - currentRecord.Text, - Find("", - currentRecord.Text - ) - Len(" 0, - Left( - Last( - Split( - currentRecord.Name, - "/" - ) - ).Value, - Find( - "?", - Last( - Split( - currentRecord.Name, - "/" - ) - ).Value + Left(currentRecord.Name, 8) = "https://", + Substitute(currentRecord.Name, " ", "%20"), + Substitute( + Topic.externalWebsiteURL & currentRecord.Name, + " ", + "%20" + ) & + If( + EndsWith(currentRecord.Name, ".pdf") && + !IsBlank(currentRecord.Text) && + Find("", currentRecord.Text) - Find(" 0, + Left( + Last(nameParts).Value, + Find("?", Last(nameParts).Value) + ), + Last(nameParts).Value + ), + "%20", + " " + ) + ) & "\""" + ) ), - Char(10) & Char(10) + Char(13) & Char(10) ) ) - kind: SendActivity id: sendActivity_i4mW3G - activity: "{Left(System.Response.FormattedText, Find(\"[1]:\", System.Response.FormattedText) + -1) & Text(Topic.CitationsSnip)}" + activity: =Left(System.Response.FormattedText, Find("[1]:", System.Response.FormattedText) - 1) & Text(Topic.CitationsSnip) - kind: SetVariable id: setVariable_jVzQGX From 806520087080a473929a7cccbb9cf148316f864c Mon Sep 17 00:00:00 2001 From: Marco Zamana Date: Fri, 6 Jun 2025 23:45:48 +0200 Subject: [PATCH 2/2] fix on yaml file remove a comment --- OnGeneratedResponse/swap-citations.yml | 129 ++++++++++++++++--------- 1 file changed, 83 insertions(+), 46 deletions(-) diff --git a/OnGeneratedResponse/swap-citations.yml b/OnGeneratedResponse/swap-citations.yml index 15498e8b..5b0b7229 100644 --- a/OnGeneratedResponse/swap-citations.yml +++ b/OnGeneratedResponse/swap-citations.yml @@ -2,7 +2,7 @@ kind: AdaptiveDialog beginDialog: kind: OnGeneratedResponse id: main - condition: =CountRows(System.Response.Citations) > 0 + condition: =CountRows(System.Response.Citations)>0 actions: - kind: SetVariable id: setVariable_wtNwaw @@ -12,64 +12,101 @@ beginDialog: - kind: SetVariable id: setVariable_9IFwdP variable: Topic.CitationsSnip - value: | + value: |- =With( - { CitationsTable: System.Response.Citations }, + {CitationsTable: System.Response.Citations}, Concat( ForAll( - Sequence(CountRows(CitationsTable)) As seqItem, - With( - { currentRecord: Index(CitationsTable, seqItem.Value) }, - "[" & Text(seqItem.Value) & "]: " & + Sequence(CountRows(CitationsTable)), + Value + ), + With( + { + currentRecord: Index( + CitationsTable, + Value + ) + }, + //begin logic + "[" & Text(Value) & "]: " & If( + IsBlank(currentRecord.Url), If( - IsBlank(currentRecord.Url), + Left( + currentRecord.Name, + 8 + ) = "https://", + Substitute( + currentRecord.Name, + " ", + "%20" + ), + Substitute((Topic.externalWebsiteURL & currentRecord.Name), " ", "%20") & + // If( - Left(currentRecord.Name, 8) = "https://", - Substitute(currentRecord.Name, " ", "%20"), - Substitute( - Topic.externalWebsiteURL & currentRecord.Name, - " ", - "%20" - ) & - If( - EndsWith(currentRecord.Name, ".pdf") && - !IsBlank(currentRecord.Text) && - Find("", currentRecord.Text) - Find("", + currentRecord.Text + ) - Len(" 0, - Left( - Last(nameParts).Value, - Find("?", Last(nameParts).Value) - ), - Last(nameParts).Value - ), - "%20", - " " - ) - ) & "\""" - ) + Text(currentRecord.Id) + ), + currentRecord.Url + ) & " " & """" & + Substitute( + If( + Find( + "?", + Last( + Split( + currentRecord.Name, + "/" + ) + ).Value + ) > 0, + Left( + Last( + Split( + currentRecord.Name, + "/" + ) + ).Value, + Find( + "?", + Last( + Split( + currentRecord.Name, + "/" + ) + ).Value + ) + ), + Last( + Split( + currentRecord.Name, + "/" + ) + ).Value + ), + "%20", + " " + ) & """" + //end logic ), - Char(13) & Char(10) + Char(10) & Char(10) ) ) - kind: SendActivity id: sendActivity_i4mW3G - activity: =Left(System.Response.FormattedText, Find("[1]:", System.Response.FormattedText) - 1) & Text(Topic.CitationsSnip) + activity: "{Left(System.Response.FormattedText, Find(\"[1]:\", System.Response.FormattedText) + -1) & Text(Topic.CitationsSnip)}" - kind: SetVariable id: setVariable_jVzQGX