Power Apps富文本多级项目符号转纯文本符号适配Power Automate
问题
- 场景:无第三方连接器,通过Power Automate从SharePoint列表取数创建Word文档,而SharePoint列表的数据来自Power Apps表单。
- 核心矛盾:Power Apps用户需要在输入中添加项目符号,但Power Automate仅支持处理纯文本。
拟定解决方案
在Power Apps表单中设置两个字段:
- 名为
RichInput的富文本字段,供用户输入带项目符号的内容 - 名为
PlainInput的隐藏纯文本字段,用于存储转换后的纯文本
需要编写Power Fx代码实现:
- 识别
RichInput中的一级项目符号,替换为星号* - 识别
RichInput中的二级嵌套项目符号,替换为连字符- - 将转换后的结果存入
PlainInput,方便Power Automate处理
尝试过的代码(未达到预期效果)
With( { htmlContent: RichText.HtmlText }, // 2. Split into Lines With( { linesTable: Split(htmlContent, Char(10)) // Split by newline character }, // 3. Iterate and Modify (and 4. Reconstruct) Set( varModifiedHtml, // A variable to store the modified HTML Concat( ForAll( linesTable, If( "</ul></li></ul>" in ThisRecord.Value, "-" & ThisRecord.Value, // Prepend hyphen ThisRecord.Value ) ), Value, "<br>" // Rejoin with HTML line breaks ) ) ) );
恳请提供可行的Power Fx代码实现上述转换需求。
内容的提问来源于stack exchange,提问作者Jarrell Cathcart
相关产品推荐
相关产品推荐

