【问题标题】:PowerApps SubmitForm to another datasourcePowerApps SubmitForm 到另一个数据源
【发布时间】:2018-12-06 17:36:52
【问题描述】:

我正在尝试实现 Outlook 等离线功能。如果离线,它应该将 EditForm1 中的值放置到本地集合(发件箱)。是否可以根据 Connection.Connected 变量将编辑表单提交给不同的来源?然后,我将创建一个计时器,在每 x 秒连接时提交它的返回。

【问题讨论】:

    标签: powerapps


    【解决方案1】:

    如果我理解正确,您希望将 EditForm1 中的当前内容保存到本地集合中,并在再次收到互联网连接后,您希望再次提交表单。

    如果您已连接到互联网,您将需要使用条件来保存表单中当前存在的数据,否则将其收集到临时集合中。

    If(ToggleIsConnected.Value,
        //If you are connected to the internet, then write the data to the database.
        SubmitForm(Form1),
    
        //If you are NOT connected to the internet, then write the data to a temporary collection to be written later.
        Collect(temporary,
            {id: Max(temporary,id)+1,
                column1: InputColumn1.Text,
                column2: InputColumn2.Text
            }
        );
        SaveData(temporary,"temporary")
    )
    

    您可以使用切换来检查互联网连接。如果您失去连接、在本地保存数据并重新连接,切换将触发并自动执行 OnCheck 操作:

    If(!IsEmpty(temporary),
        // If the connection returns and there are records to be written, 
        // then perform these actions:
        ForAll(temporary,
            // For each of the records in the temporary collection, 
            // save their data to a new row in the connected datasource.
    
            // If writing was successful, copy it to a collection called 'success' 
            // to identify it.
            Collect(success,
                {id: id,
                    Record:                     
                        Patch(datasource,Defaults(datasource),
                            {column1: column1,
                                column2: column2
                            }
                        )
                }
            )
        );
    
        If(IsEmpty(Errors(datasource)),
            // If there are no errors with the datasource, 
            // go ahead and clear the entire temporary collection since you're writing.
            Clear(temporary),
    
            // Otherwise if there is an error, remove only the records that were successful. 
            // Then clear the successful records.
            // Keep records that had an error so they could be attempted later.
            Remove(temporary,Filter(temporary,id exactin Filter(success,!IsBlank(Record)).id));
            Clear(success)
        )
    )
    

    请注意,这里我使用 Patch() 来保存临时集合中的内容。除非我填写表单,否则我无法使用 SubmitForm。

    要进一步实现这一点,还需要执行更多步骤。请查看我关于此主题的视频以获取更详细的详细信息: https://www.youtube.com/watch?v=j30xOM5OmRE

    【讨论】:

      猜你喜欢
      • 2017-03-02
      • 2020-07-16
      • 2014-11-16
      • 2022-07-20
      • 1970-01-01
      • 1970-01-01
      • 2011-05-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多