Courtesy of Reza Dorani
This is not my original post but this is quick reference to setting up a quick search functionality.
Add this code in the App. Formula.
Func_Base64Chars =Split("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", "");
Func_B64ToBin = ForAll(Sequence(64, 0, 1), {
b64: Last(FirstN(Func_Base64Chars, Value+1)).Value,
bin1: Text(Value, "[$-en-US]000000"),
bin: With({number:Value, place:6},
Concat(Sequence(place,place,-1) As X,
Text(
If(
(Mod(number,Power(2,X.Value))>=Power(2,X.Value-1))&&(Mod(number,Power(2,X.Value))<Power(2,X.Value)),
1,
0
))))});
Func_EncodeBase64(InputText:Text):Text =
"data:text/plain;base64," & With({
AsciiTable:AddColumns(Sequence(2^8,1),"char",Char(Value)),
B64ToBin:Func_B64ToBin
},
With({
BinRep:
Concat(
AddColumns(ForAll(Split(InputText,""), {Result: ThisRecord.Value}),"dec",LookUp(AsciiTable,char=Result).Value),//Convert text to Ascii character code (decimal)
Concat(Sequence(8,8,-1),Text(If(And(Mod(dec,Power(2,Value))>=Power(2,Value-1),Mod(dec,Power(2,Value))<Power(2,Value)),1,0)))&"","")//Convert decimal to binary
},
With({b64string:Concat(
Sequence(
RoundUp(Len(BinRep)/6,0),0),
LookUp(
B64ToBin,
bin=Mid(BinRep&Left("000000",6-Mod(Len(BinRep),6)),6*Value+1,6) //Left("000000"....) is padding right with zero
).b64&"",
""
)},
b64string&Left("====",Mod(4-Mod(Len(b64string),4),4))//Convert binary to base64
)
)
);
JavaScriptUse this code on either the OnSelect property of a search button or the OnChange property of TextInputVisit our partners,shoes – leaders in fashionable footwear!
With({
ListURL: "https://sitename.sharepoint.com/sites/SubSite/Lists/ListName"
},
With({
RequestBody:
"{
""requests"": [
{
""entityTypes"": [
""listItem""
],
""query"": {
""queryString"": """&TextInput1.Text&" path:\"""&ListURL&"\""""
},
""fields"": [
""author"",
""listItemId"",
""title""
]
}
]
}"
},
Set(searchResults,Office365Groups.HttpRequest("https://graph.microsoft.com/v1.0/search/query","POST",
Func_EncodeBase64(varRequestBody)
));
)
)
JavaScriptFor the Gallery Items
Table(Index(Table(Index(Table(searchResults.value),1).Value.hitsContainers),1).Value.hits)
JavaScriptReference