Power Apps Exchange

Please login or click SIGN UP FOR FREE to create your PowerAppsUG account to join this user group.
 View Only
  • 1.  Setting variable to NOW() and then using variable in Patch command

    Posted Apr 21, 2022 03:53 PM
    I have a Power App that uses parent and child SharePoint lists.

    In the child list (CRSP-Workflow), there is a Status drop-down field. If the user selects "Complete," I need to update the Completion Date field in the parent list (CRSP-Main), which is a DateTime column in the SharePoint list.

    Here's what I've tried.

    In child list form (frmWorkflow):


    • Dropdown is NewStatus (DataCardValue28).
    • In OnChange property of DataCardValue28, I want it to set variable only if the user selects Complete. Otherwise, do nothing. I have tried all of these:
      • If("Complete" in DataCardValue28.SelectedItems.Value, Set(varCompletionDate, (Now())))
      • If("Complete" in DataCardValue28.SelectedItems.Value, Set(varCompletionDate, Text((Now()))))
      • If("Complete" in DataCardValue28.SelectedItems.Value, Set(varCompletionDate, DateTimeValue((Now()))))
    • I have a label on the form containing the variable - with all of these commands, the variable looks correct:



    Here's the Patch command in the OnSuccess of frmWorkflow:

    If(
    !IsBlank(varCompletionDate),
    Patch
    (
    'CRSP-Main',varRecord,
    {'Date Completed': {Value:varCompletionDate}
    }
    )
    );

    This is the error message:


    I read somewhere (which of course I can't find again) that Now() is a record.

    Can anyone help me with this?

    Thanks.



    ------------------------------
    Lisa White
    Senior IT Specialist
    Herndon VA
    703-709-7172
    ------------------------------


  • 2.  RE: Setting variable to NOW() and then using variable in Patch command

    Silver Contributor
    Posted Apr 22, 2022 05:09 AM
    Hi Lisa,

    please try to use the Now() function directly in your Patch statement instead of having it in a variable.
    You could try something like this:

    if(
    "Complete" in DataCardValue28.SelectedItems.Value,
    Patch(
    'CRSP-Main',varRecord,
    {'Date Completed': Now()
    }
    )
    )

    Let us know if this works or not

    ------------------------------
    Koen Mathijs
    ------------------------------



  • 3.  RE: Setting variable to NOW() and then using variable in Patch command

    Posted Apr 25, 2022 11:06 AM
    Thanks, Koen. That worked! Here's the new code:

    If(
    varCompleted ="Yes",
    Patch
    (
    'CRSP-Main',varRecord,
    {'Date Completed': Now()
    }
    ),
    Patch
    (
    'CRSP-Main',varRecord,
    {'Date Completed': Blank()}
    )
    )

    ------------------------------
    Lisa White
    Senior IT Specialist
    Herndon VA
    703-709-7172
    ------------------------------