【问题标题】:Parse JSON action in Flow fails from the PowerApp从 PowerApp 解析 Flow 中的 JSON 操作失败
【发布时间】:2021-09-28 07:46:47
【问题描述】:

我有一个非常基本的 Power App,只有很少的输入字段和上传图片。 Submit 上的应用程序调用流程,然后将提交详细信息传递给 Salesforce。这很好用,但是当用户不上传图片时,流程会失败

 Parse_JSON failed -- "message": "Invalid type. Expected String but got Null.",

提交按钮的逻辑是这样的

Set(varFileExt, Right(AddImageButton.FileName, 3));
Clear( FormInfo );
Collect(FormInfo,
    {
        idOrNameDetail : IdOrNameDetails.Text,
        projectGUID: GUID(),
        picUri: AddedImage.Image,
        picFilename:
            If(
                AddImageButton.FileName = "image.jpg",
                Concatenate(
                    Text(Now(), "[$-en-US]yyyy-mm-dd_hhmmss"),
                    ".jpg"
                ),
                AddImageButton.FileName
            ),
        fileExtension: varFileExt,
        picJSON: 
            If(
                Or(
                    Lower(varFileExt) = "jpg",
                    Lower(varFileExt) = "jpeg"
                ),
                    Mid(JSON(AddedImage.Image, IncludeBinaryData), 25, Len(JSON(AddedImage.Image, IncludeBinaryData)) - 25),
                
                Lower(varFileExt) = "png",
                    Mid(JSON(AddedImage.Image, IncludeBinaryData), 24, Len(JSON(AddedImage.Image, IncludeBinaryData)) - 24)
            )
    }
);

Set(FormObj, JSON(FormInfo, IncludeBinaryData));
SFIncidentCreation.Run(FormObj);    

Reset(IdOrNameDetails);
Reset(AddImageButton);

如何编写 JSON 检查图像是否添加。非常感谢任何帮助

【问题讨论】:

    标签: powerapps power-automate powerapps-canvas


    【解决方案1】:

    我假设您尝试只保存一条记录,在这种情况下,使用 Cotext 变量比使用 Colecction 更好。

         UpdateContext({   myData: {
                  idOrNameDetail : IdOrNameDetails.Text,
                  projectGUID: GUID(),
                  picUri: AddedImage.Image,
                  picFilename: If(
                     AddImageButton.FileName = "image.jpg",
                     Concatenate(Text(Now(), "[$-en-US]yyyy-mm-dd_hhmmss"),".jpg"),
                     AddImageButton.FileName
                  ),
                  fileExtension: Right(AddImageButton.FileName, 3),
                  picJSON: If(
                     Or(Lower(varFileExt) = "jpg",Lower(varFileExt) = "jpeg"),
                     Mid(
                        JSON(AddedImage.Image, IncludeBinaryData),
                        25,
                        Len(JSON(AddedImage.Image, IncludeBinaryData)) - 25
                     ),
                     Lower(varFileExt) = "png", 
                     Mid(
                        JSON(AddedImage.Image, IncludeBinaryData),
                        24,
                        Len(JSON(AddedImage.Image, IncludeBinaryData)) - 24
                     )
                  )
               }
          });
    Set(FormObj, JSON(myData));
    SFIncidentCreation.Run(FormObj);
    Reset(IdOrNameDetails);
    Reset(AddImageButton);
    

    【讨论】:

    • PowerAutomate(Flow) 中的 Pare_JSON 仍然失败。说预期是字符串,但收到空值。当用户不上传图片时如何处理它
    【解决方案2】:

    几个想法:

    1. picJSON 作为required 字段从Parse_JSON 架构中移除
    2. Parse_JSON 操作之前放置一个条件,检查该字段是否为空,然后执行适当的操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-03
      • 1970-01-01
      • 2016-05-31
      • 2015-10-05
      • 1970-01-01
      • 2020-02-05
      相关资源
      最近更新 更多