listtrackingpowerappssequentialforall

Kinda newbie: PowerApps to populate a list with constructed data fields


Updated...

Trying to inject a series of rows into a SharePoint List via PowerApps, but running across the fact that PowerApps seems to only have FORALL as a looping function, and that does not support SET.

   Set(AlertString,""); // to be used later
   Set(REQ_Value,"");
   Set(RITM_Value,"");
   Set(Asset_Value,"");
   Set(CustomerSignatureFileLocation_Value,"File location: ");
   Set(LoanerKitCode_Value,"");
   Set(IncidentCode_Value,"");
   Set(TransferOrderCode_Value,"");
   Set(TransactionType_Value,Workflow.SelectedText.Value & " - " & Workflow_Steps.SelectedText.Value);
   Set(ScanItemCodeType,"");
   Set(ErrorString,"");
   Collect(ScanDataCollection,Split(ScanData.Text,Char(10))); // Split the data into ScanDataCollection collection
   ForAll(
       ScanDataCollection,
       If(Left(Result,4)="RITM",Set(RITM_Value,Result); // FAIL HERE
       Collect('Spider - Master Transaction List', {
           REQ: REQ_Value,
           RITM: RITM_Value,
           Scan_Code: Result,
           Asset: Asset_Value,
           Transaction_Type: TransactionType_Value,
           Timestamp: Now(),
           Agent_Name: User().FullName,
           Agent_Email: User().Email,
           Agent_Location: DD_Location.SelectedText.Value,
           Agent_Notes: "It was weird, man.",
           Customer_Name: Cust_Name.Text,
           Customer_Email: Cust_NTAccount.Text,
           Customer_Signature: CustomerSignatureFileLocation_Value,
           Task_Name: "",
           Task_Action: "",
           State_Name: "",
           State_Action: "",
           Stage_Name: "",
           Stage_Action: "",
           Work_Note_String: "",
           Customer_Note_String: "",
           Loaner_Kit_Code: LoanerKitCode_Value,
           Incident: IncidentCode_Value,
           Transfer_Order_Code: TransferOrderCode_Value,
           Item_Description: ""});
   );

My scanner tool will pick up a variety of different kinds of item scans, all in the same scan. Depending on what type of data it is, it populates different columns in Spider - Master Transaction List.

But we are forbidden to use the SET function inside a FORALL.

How would you recommend I approach this -- considering that each piece of data from the SPLIT could be any of the sorts of codes (such as RITM Code, REQ Code, Transfer Order Code, etc.)?


Solution

  • You can do that you want on various way.

    Using Collection or Gallery, in powrapps Galleries can be used like a collection.

    I Suggest:

    ForAll(
      Gallery.Allitems, 
      Patch(
       'SharepointListName',      
       ThisRecord
      )
    );
    

    Fields in gallery must have the same name of sharepoint list, or you have to create a record to asign the names.

    {sharepoitColumnName: ThisRecord.ColumnName, ...}